Image processing device and image processing program

ABSTRACT

An image processing apparatus includes: an image obtaining unit that obtains an image captured with an image sensor; and a defect information generating unit that generates defect information indicating a defect within the image having been obtained, based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel.

The disclosures of the following priority applications are hereinincorporated by reference:

Japanese Patent Application No. 2002-379719 filed Dec. 27, 2002

Japanese Patent Application No. 2002-379720 filed Dec. 27, 2002

Japanese Patent Application No. 2002-379721 filed Dec. 27, 2002

Japanese Patent Application No. 2003-307355 filed Aug. 29, 2003

Japanese Patent Application No. 2003-307356 filed Aug. 29, 2003

Japanese Patent Application No. 2003-307357 filed Aug. 29, 2003

TECHNICAL FIELD

The present invention relates to an image processing apparatus thateliminates the adverse effect of dust and the like in image dataobtained by photographing an image with an electronic camera or thelike.

BACKGROUND ART

A technology in the related art whereby a white pattern is photographedat each aperture value and correction information is recorded in advanceto be used to correct the adverse effect of dust that has entered theoptical systems while manufacturing a video camera is disclosed inJapanese Laid Open Patent Publication No. H9-51459. In addition,Japanese Laid Open Patent Publication No. H10-294870 and Japanese LaidOpen Patent Publication No. H11-27475 each disclose a technology fordetecting dust by taking in white reference data from a uniformreflecting surface prior to the original copy read, to be adopted incopiers in which the dust conditions may change constantly. Also, U.S.Pat. No. 6,195,161 discloses a method for obtaining an attenuationsignal indicating the attenuation of transmittance attributable to afilm defect by obtaining transmittance data concurrently as visiblelight data are obtained with an infrared sensor instead of the whitereference data, to be adopted in scanners.

DISCLOSURE OF THE INVENTION

However, the anti-dust measures adopted in cameras in the related artonly target fixed dust having become adhered to optical componentsduring the manufacturing process and do not deal with dust, theconditions of which may change over time depending upon the frequency ofuse. The problem of dust conditions that change over time appearing inphotographed images tends to be more serious in single lens reflexcameras that allow the use of exchangeable lenses, which are gainingpopularity today, since the optical components disposed to the front ofthe image sensor are uncovered.

In the area of copiers and scanners, dust data are obtained prior to orconcurrently with the main scan, to be used to eliminate the adverseeffect of dust that changes over time. Since a copier or a scanner,unlike a camera, includes an illuminating means that uniformlyilluminates the surface of an original copy or the film surface set at afixed distance, transmittance data can be obtained relatively easily byadding a completely uniform reflecting surface or by further providingan infrared illuminating means. However, except for during theinspection conducted in the manufacturing process, transmittance data ofa completely uniform surface cannot be obtained readily with anelectronic camera.

In addition, since copiers and scanners are basically fixed opticalsystems, it is not necessary to be concerned with changes occurring inthe dust conditions due to changes in the states of the optical systems.Video cameras in the related art are not designed to handle changes inthe optical conditions other than the aperture value.

The present invention provides an image processing apparatus and animage processing program, with which the adverse effect of dust or thelike can be eliminated in a desirable manner from image data obtained byphotographing an image with an electronic camera or the like.

According to the 1st aspect of the invention, an image processingapparatus comprises: an image obtaining unit that obtains an imagecaptured with an image sensor; and a defect information generating unitthat generates defect information indicating a defect within the imagehaving been obtained, based upon a value at a target pixel and anaverage value of a plurality of pixel values corresponding to pixelspresent within a predetermined range containing the target pixel.

According to the 2nd aspect of the invention, in the image processingapparatus according to the 1st aspect, it is preferred that: the defectinformation generating unit includes a relative ratio calculation unitthat calculates a relative ratio of the value at the target pixel andthe average value of the plurality of pixel values corresponding to thepixels present within the predetermined range containing the targetpixel, and generates the defect information based upon the calculatedrelative ratio.

According to the 3rd aspect of the invention, in the image processingapparatus according to the 1st or the 2nd aspect, it is preferred that:the defect information generating unit generates defect information foran area within the image, which satisfies a predetermined condition.

According to the 4th aspect of the invention, in the image processingapparatus according to any of the 1st through 3rd aspects, it ispreferred that: there is further provided a correction unit thatcorrects the defect within the image based upon the defect information.

According to the 5th aspect of the invention, in the image processingapparatus according to the 2nd aspect, it is preferred that: there isfurther provided a correction unit that corrects the defect within theimage based upon the defect information; and the correction unitcorrects the defect by multiplying a value at a corresponding pixel by areciprocal of the relative ratio.

According to the 6th aspect of the invention, in the image processingapparatus according to the 1st aspect, it is preferred that: the imageobtaining unit obtains a plurality of images captured with the imagesensor; and the defect information generating unit generates defectinformation indicating a defect within one of the plurality of images byusing the plurality of images having been obtained.

According to the 7th aspect of the invention, in the image processingapparatus according to the 1st aspect, it is preferred that: the imageobtaining unit obtains a plurality of images captured with the imagesensor; and the defect information generating unit generates defectinformation corresponding to an entire image of each of the plurality ofimages by using the plurality of images having been obtained.

According to the 8th aspect of the invention, an image processingapparatus comprises: an image obtaining unit that obtains a referenceimage photographed through an optical system; and a defect informationgenerating unit that generates defect information indicating a defectwithin the reference image having been obtained, based upon a value of atarget pixel and an average value of a plurality of pixel valuescorresponding to pixels present within a predetermined range containingthe target pixel in the reference image.

According to the 9th aspect of the invention, in the image processingapparatus according to the 8th aspect, it is preferred that: the defectinformation generating unit includes a relative ratio calculation unitthat calculates a relative ratio of the value at the target pixel andthe average value of the plurality of pixel values corresponding to thepixels present within the predetermined range containing the targetpixel, and generates the defect information based upon the calculatedrelative ratio.

According to the 10th aspect of the invention, in the image processingapparatus according to the 8th or the 9th aspect, it is preferred that:the image obtaining unit obtains a correction target image photographedthrough the optical system; and there is further provided a correctionunit that corrects a defect within the correction target image basedupon the defect information within the reference image.

According to the 11th aspect of the invention, in the image processingapparatus according to the 10th aspect, it is preferred that: if thereference image and the correction target image have been photographedthrough an optical system in substantially identical optical conditionswith regard to an aperture value and a pupil position, the correctionunit corrects a value at a pixel constituting the correction targetimage by directly using the defect information having been generated.

According to the 12th aspect of the invention, in the image processingapparatus according to the 10th aspect, it is preferred that: there isfurther provided a defect information conversion unit that converts thedefect information in correspondence to at least either of an aperturevalue and a pupil position constituting optical conditions of theoptical system; and if the reference image and the correction targetimage have been photographed through the optical system under differentoptical conditions with regard to at least either the aperture value orthe pupil position, the correction unit corrects a value at a pixelconstituting the correction target image by using the converted defectinformation.

According to the 13th aspect of the invention, in the image processingapparatus according to the 9th aspect, it is preferred that: there isfurther provided a correction unit that corrects a value of acorresponding pixel in the correction target image by multiplying thevalue of the corresponding pixel with a reciprocal of the relative ratiocalculated for the reference image.

According to the 14th aspect of the invention, in the image processingapparatus according to the 2nd or the 9th aspect, it is preferred that:the relative ratio calculation unit sets the calculated relative ratioto 1 if the calculated relative ratio falls within a predetermined rangecontaining 1.

According to the 15th aspect of the invention, in the image processingapparatus according to the 14th aspect, it is preferred that: therelative ratio calculation unit correlates the predetermined range overwhich the calculated relative ratio is set to 1 with a standarddeviation value of the calculated relative ratio.

According to the 16th aspect of the invention, in the image processingapparatus according to the 1st or the 8th aspect, it is preferred that:the predetermined range containing the target pixel is greater than adefect area manifesting within the image or the reference image.

According to the 17th aspect of the invention, in the image processingapparatus according to the 10th aspect, it is preferred that: the imageobtaining unit obtains a reference image photographed within apredetermined period of time preceding or following a time point atwhich the correction target image is photographed.

According to the 18th aspect of the invention, in the image processingapparatus according to the 17th aspect, it is preferred that: the imageobtaining unit obtains a reference image photographed at a time pointclosest to or second closest to a time point at which the correctiontarget image is photographed.

According to the 19th aspect of the invention, an image processingapparatus comprises: an image obtaining unit that obtains an imagecaptured by using an image sensor capable of separating light into aplurality of colors; a luminance signal generating unit that generates aluminance signal based upon signals of the plurality of colorsconstituting the image; and a defect information generating unit thatgenerates defect information indicating a defect within the image basedupon the luminance signal for the image having been generated.

According to the 20th aspect of the invention, in the image processingapparatus according to the 19th aspect, it is preferred that: there isfurther provided a correction unit that corrects a value correspondingto a color component at a defective pixel within the image by using thedefect information.

According to the 21st aspect of the invention, in the image processingapparatus according to the 19th aspect, it is preferred that: there isfurther provided a defect information generating unit that generatesdefect information indicating a defect within the image having beenobtained based upon a value indicated by the luminance signal generatedfor a target pixel and an average value among values indicated byluminance signals generated for a plurality of pixels within apredetermined range containing the target pixel.

According to the 22nd aspect of the invention, in the image processingapparatus according to the 21st aspect, it is preferred that: the defectinformation generating unit includes a relative ratio calculation unitthat calculates a relative ratio of the value indicated by the luminancesignal generated for the target pixel and the average value of theluminance signals generated for the plurality of pixels within thepredetermined range containing the target pixel, and generates thedefect information based upon the relative ratio having been calculated.

According to the 23rd aspect of the invention, in the image processingapparatus according to the 21st aspect, it is preferred that: there isfurther provided a correction unit that corrects a value correspondingto a color component at a corresponding pixel by multiplying the valueby a reciprocal of the relative ratio.

According to the 24th aspect of the invention, in the image processingapparatus according to the 19th aspect, it is preferred that: the imageobtaining unit obtains a plurality of images captured with the imagesensor; the luminance signal generating unit generates the luminancesignals for the plurality of images having been obtained; and the defectinformation generating unit generates defect information indicating adefect within an image among the plurality of images by using theluminance signals generated for the plurality of images.

According to the 25th aspect of the invention, in the image processingapparatus according to the 19th aspect, it is preferred that: the imageobtaining unit obtains a plurality of images captured with the imagesensor; the luminance signal generating unit generates luminance signalsfor the plurality of images having been obtained; and the defectinformation generating unit generates defect information correspondingto an entire image of each of the plurality of images by using theplurality of images having been obtained.

According to the 26th aspect of the invention, in the image processingapparatus according to the 1st aspect, it is preferred that: the imagesensor captures an image through an optical system; and the defectinformation is information on a projected image of a defect within anoptical path, which manifests in the image.

According to the 27th aspect of the invention, in the image processingapparatus according to the 26th aspect, it is preferred that: the defectinformation generating unit simultaneously generates informationindicating a position of the projected image of the defect within theoptical path and information indicating intensity of the projected imageof the defect within the optical path and records the positioninformation and the intensity information.

According to the 28th aspect of the invention, in the image processingapparatus according to the 27th aspect, it is preferred that: the defectinformation generating unit moves the predetermined range over which theaverage value is calculated for each target pixel and generatescontinuous sets of information related to the intensity of the projectedimage of the defect within the optical path.

According to the 29th aspect of the invention, in the image processingapparatus according to the 4th aspect, it is preferred that: thecorrection unit determines a correction value by using an initial signalvalue indicated at a correction target pixel position.

According to the 30th aspect of the invention, in the image processingapparatus according to the 8th aspect, it is preferred that: the defectinformation is information on a projected image of a defect within anoptical path, which manifests in the image.

According to the 31st aspect of the invention, in the image processingapparatus according to the 30th aspect, it is preferred that: the defectinformation generating unit simultaneously generates informationindicating a position of the projected image of the defect within theoptical path and information indicating intensity of the projected imageof the defect within the optical path and records the positioninformation and the intensity information.

According to the 32nd aspect of the invention, in the image processingapparatus according to the 31st aspect, it is preferred that: the defectinformation generating unit moves the predetermined range over which theaverage value is calculated for each target pixel and generatescontinuous sets of information related to the intensity of the projectedimage of the defect within the optical path.

According to the 33rd aspect of the invention, in the image processingapparatus according to the 10th aspect, it is preferred that: thecorrection unit determines a correction value by using an initial signalvalue indicated at a specific correction target pixel position.

According to the 34th aspect of the invention, in the image processingapparatus according to the 15th aspect, it is preferred that: therelative ratio calculation unit sets the predetermined range over whichthe calculated relative ratio is set to 1 to a±(3×standard deviationvalue) range.

According to the 35th aspect of the invention, in the image processingapparatus according to the 26th aspect, it is preferred that: thepredetermined range containing the target pixel is greater than a rangeover which the projected image of the defect within the optical pathspreads inside the image.

According to the 36th aspect of the invention, in the image processingapparatus according to the 30th aspect, it is preferred that: thepredetermined range containing the target pixel is greater than a rangeover which the projected image of the defect within the optical pathspreads inside the reference image.

According to the 37th aspect of the invention, an image processingapparatus comprises: an image obtaining unit that obtains a first imagephotographed through an optical system and a second image photographedunder optical conditions different from optical conditions in which thefirst image is photographed; and a defect information generating unitthat generates defect information indicating a defect in the first imageor the second image by using the first image and the second image.

According to the 38th aspect of the invention, in the image processingapparatus according to the 37th aspect, it is preferred that: there isfurther provided a correction unit that corrects a defect in the firstimage or the second image by using the defect information.

According to the 39th aspect of the invention, in the image processingapparatus according to the 37th aspect, it is preferred that: the firstimage and the second image are photographed under different opticalconditions with regard to at least either of an aperture value and apupil position.

According to the 40th aspect of the invention, in the image processingapparatus according to any of the 37th through 39th aspects, it ispreferred that: the defect information generating unit includes anoptical condition conversion unit that converts at least either thefirst image or the second image so as to conform to a specific opticalcondition, in order to eliminate a mismatch of the optical conditionsfor the first image and the second image.

According to the 41st aspect of the invention, in the image processingapparatus according to the 40th aspect, it is preferred that: if theoptical conditions with regard to the aperture value are different, theoptical condition conversion unit executes low pass filter processing ona pixel signal generated based upon the first image or the second imageso as to convert a defect state corresponding to the first image or thesecond image to a defect state estimated to manifest at a matchingaperture value.

According to the 42nd aspect of the invention, in the image processingapparatus according to the 41th aspect, it is preferred that: theoptical condition conversion unit executes conversion by using asubstantially uniformly weighted low pass filter.

According to the 43rd aspect of the invention, in the image processingapparatus according to the 40th aspect, it is preferred that: if theoptical conditions with regard to the pupil position are different, theoptical condition conversion unit executes displacement processingthrough which a pixel signal generated based upon the first image or thesecond image is displaced from a center of an optical axis of theoptical system along a direction of a radius vector so as to covert adefect state corresponding to the first image or the second image to adefect state estimated to manifest at a matching pupil position.

According to the 44th aspect of the invention, in the image processingapparatus according to the 43th aspect, it is preferred that: theoptical condition conversion unit executes displacement processingthrough which a pixel signal located further away from the center of theoptical axis is shifted to a greater extent along the radius vector.

According to the 45th aspect of the invention, in the image processingapparatus according to the 43rd or the 44th aspect, it is preferredthat: the optical condition conversion unit executes the displacementprocessing by executing an arithmetic operation to predict an extent ofdisplacement on an assumption that foreign matter causing the defect ispresent over a specific distance from an image-capturing surface withinthe optical system along the optical axis.

According to the 46th aspect of the invention, in the image processingapparatus according to the 37th aspect, it is preferred that: one of thefirst image and the second image is a correction target image to undergocorrection and the other image is a reference image used to generate thedefect information.

According to the 47th aspect of the invention, in the image processingapparatus according to the 37th aspect, it is preferred that: the firstimage and the second image are both correction target images to undergocorrection; and the defect information generating unit generates defectinformation to be used commonly in conjunction with the first image andthe second image by using the first image and the second image.

According to the 48th aspect of the invention, in the image processingapparatus according to the 47th aspect, it is preferred that: the defectinformation generating unit includes an optical condition conversionunit that converts at least either the first image or the second imageso as to conform to a specific optical condition, in order to eliminatea mismatch of the optical conditions for the first image and the secondimage.

According to the 49th aspect of the invention, in the image processingapparatus according to the 46th aspect, it is preferred that: the imageobtaining unit obtains the reference image photographed at an aperturevalue corresponding to a narrowest aperture opening setting in anadjustable aperture value range of the optical system.

According to the 50th aspect of the invention, in the image processingapparatus according to the 37th aspect, it is preferred that: the defectinformation generating unit generates defect information indicating adefect within the image having been obtained, based upon a value of atarget pixel and an average value of a plurality of pixel valuescorresponding to pixels present within a predetermined range containingthe target pixel in the image.

According to the 51st aspect of the invention, in the image processingapparatus according to the 46th or the 49th aspect, it is preferredthat: the image obtaining unit obtains a reference image photographedwithin a predetermined period of time preceding or following a timepoint at which the correction target image is photographed.

According to the 52nd aspect of the invention, an image processingapparatus comprises: an image obtaining unit that obtains a first imagephotographed through an optical system and a second image photographedunder optical conditions different from optical conditions in which thefirst image is photographed; and a correction unit that corrects adefect contained within the first image or the second image by using thefirst image and the second image.

According to the 53rd aspect of the invention, in the image processingapparatus according to the 52th aspect, it is preferred that: the firstimage and the second image are photographed under different opticalconditions with regard to at least either of an aperture value and apupil position.

According to the 54th aspect of the invention, an image processingapparatus comprises: an image obtaining unit that obtains a photographicimage captured with an image sensor; a flat portion extraction unit thatextracts a flat portion area within the photographic image having beenobtained; and a defect information generating unit that generates defectinformation corresponding to the extracted flat portion area.

According to the 55th aspect of the invention, in the image processingapparatus according to the 54th aspect, it is preferred that: there isfurther provided a correction unit that corrects an image within theflat portion area based upon the defect information.

According to the 56th aspect of the invention, in the image processingapparatus according to the 54th or the 55th aspect, it is preferredthat: the defect information corresponding to the flat portion area isgenerated based upon a value at a target pixel and an average value of aplurality of pixel values corresponding to pixels present within apredetermined range containing the target pixel in the image within theflat portion area.

According to the 57th aspect of the invention, in the image processingapparatus according to the 56th aspect, it is preferred that: the defectinformation generating unit includes a relative ratio calculation unitthat calculates a relative ratio of the value at the target pixel andthe average value of the plurality of pixel values corresponding to thepixels present within the predetermined range containing the targetpixel, and generates the defect information corresponding to the flatportion area based upon the calculated relative ratio.

According to the 58th aspect of the invention, in the image processingapparatus according to the 55th aspect, it is preferred that: there isfurther provided a relative ratio calculation unit that calculates arelative ratio of a value at a target pixel and an average value ofpixel values corresponding to a plurality of pixels present within apredetermined range containing the target pixel, among pixelsconstituting an image of the flat portion area; the defect informationgenerating unit generates the defect information corresponding to theflat portion area based upon the relative ratio having been calculated;and the correction unit uses a reciprocal of the relative ratiocorresponding to a pixel in the image of the flat portion area whencorrecting a value of the corresponding pixel in the image of the flatportion area by multiplying the pixel value by the reciprocal.

According to the 59th aspect of the invention, in the image processingapparatus according to the 58th aspect, it is preferred that: thecorrection unit executes low pass processing on the relative ratio whichhas been generated as the defect information and corrects the value ofthe corresponding pixel in the image of the flat portion area bymultiplying the pixel value by a reciprocal of the relative ratio havingundergone the low pass processing, which corresponds to the pixel in theimage of the flat portion area.

According to the 60th aspect of the invention, in the image processingapparatus according to any of the 54th through 59th aspects, it ispreferred that: the flat portion extraction unit executes edgeextraction within the photographic image and extracts an area in whichno edge is extracted as a flat portion area.

According to the 61st aspect of the invention, in the image processingapparatus according to the 54th aspect, it is preferred that: the flatportion extraction unit includes a gradation conversion unit thatexecutes gradation conversion on the photographic image and executes aflat portion area extraction on the photographic image having undergonethe gradation conversion.

According to the 62nd aspect of the invention, in the image processingapparatus according to the 61st aspect, it is preferred that: whengradation of the photographic image is indicated with a linear signal,the gradation conversion unit converts the linear signal to a nonlinearsignal.

According to the 63rd aspect of the invention, in the image processingapparatus according to the 62nd aspect, it is preferred that: thegradation conversion unit executes conversion by enlarging the gradationon a low intensity side and compressing the gradation on a highintensity side.

According to the 64th aspect, of the invention, in the image processingapparatus according to the 62nd or the 63rd aspect, it is preferredthat: the gradation conversion unit executes conversion by using a powerfunction.

According to the 65th aspect of the invention, in the image processingapparatus according to the 64th aspect, it is preferred that: the powerfunction is a square root function.

According to the 66th aspect of the invention, in the image processingapparatus according to any of the 60th through 65th aspects, it ispreferred that: the edge extraction is executed by calculatingdifferences corresponding to a plurality of distances between a targetpixel and surrounding pixels along a plurality of directions.

According to the 67th aspect of the invention, in the image processingapparatus according to any of the 55, 58 and 59th aspect, it ispreferred that: there is further provided a luminance leveldecision-making unit that makes a decision as to whether or not aluminance level of the photographic image is equal to or higher than apredetermined luminance level; and the correction unit executescorrection for an area determined to be a flat portion area, where theluminance level is equal to or greater than the predetermined level.

According to the 68th aspect of the invention, in the image processingapparatus according to the 54th aspect, it is preferred that: there isfurther provided a reference image obtaining unit that obtains areference image captured with the image sensor and a reference imagedefect information generating unit that generates defect informationcorresponding to the reference image; and the defect informationgenerating unit generates the defect information corresponding to theflat portion area by using area information included in the defectinformation for the reference image and area information correspondingto the flat portion area in combination.

According to the 69th aspect of the invention, in the image processingapparatus according to the 68th aspect, it is preferred that: if an areathat is not extracted as the flat portion area is still indicated to bea defect area by the defect information for the reference image, theflat portion extraction unit extracts the defect area as a flat portionarea.

According to the 70th aspect of the invention, in the image processingapparatus according to the 68th or the 69th aspect, it is preferredthat: the defect information generating unit generates the defectinformation for an area indicated as a defect area by the defectinformation for the reference image and also determined to be the flatportion area.

According to the 71st aspect of the invention, in the image processingapparatus according to the 68th aspect, it is preferred that: there isfurther provided a defect information conversion unit that converts thedefect information for the reference image to defect informationequivalent to defect information for a reference image photographedunder optical conditions identical to optical conditions under which thephotographic image has been photographed when the photographic image andthe reference image have been photographed under different opticalconditions; and the correction unit executes correction by using thedefect information for the reference image resulting from theconversion.

According to the 72nd aspect of the invention, in the image processingapparatus according to the 69th or the 70th aspect, it is preferredthat: there is further provided a defect information conversion unitthat converts the defect information for the reference image to defectinformation equivalent to defect information for a reference imagephotographed under optical conditions identical to optical conditionsunder which the photographic image has been photographed when thephotographic image and the reference image have been photographed underdifferent optical conditions; and the flat portion extraction unit andthe correction unit use the defect information for the reference imageresulting from the conversion.

According to the 73rd aspect of the invention, in the image processingapparatus according to the 71st or the 72nd aspect, it is preferredthat: in consideration of an error in defect information conversionexecuted by the defect information conversion unit, the correction unitexpands the defect area indicated by the defect information for thereference image, at least by an extent corresponding to the error in thedefect information conversion.

According to the 74th aspect of the invention, in the image processingapparatus according to the 54th aspect, it is preferred that: the imageobtaining unit obtains a plurality of photographic images captured withthe image sensor; the flat portion extraction unit extracts the flatportion area in each of the plurality of photographic images; and thedefect information generating unit generates defect informationcorresponding to the flat portion area in one of the plurality of imagesby using images of flat portion areas in the plurality of images havingbeen extracted.

According to the 75th aspect of the invention, in the image processingapparatus according to the 54th aspect, it is preferred that: the imageobtaining unit obtains a plurality of photographic images captured withthe image sensor; the flat portion extraction unit extracts the flatportion area in each of the plurality of photographic images; and thedefect information generating unit generates defect informationcorresponding to an entire image of each of the plurality of images byusing images of flat portion areas in the plurality of images havingbeen extracted.

According to the 76th aspect of the invention, in the image processingapparatus according to the 74th or the 75th aspect, it is preferredthat: the defect information corresponding to the flat portion area isgenerated based upon a value at a target pixel and an average value of aplurality of pixel values corresponding to pixels present within apredetermined range containing the target pixel in the image within theflat portion area.

According to the 77th aspect of the invention, in the image processingapparatus according to the 76th aspect, it is preferred that: the defectinformation generating unit includes a relative ratio calculation unitthat calculates a relative ratio of the value at the target pixel andthe average value of the plurality of pixel values corresponding to thepixels present within the predetermined range containing the targetpixel, and generates the defect information corresponding to the flatportion area based upon the calculated relative ratio.

According to the 78th aspect of the invention, in the image processingapparatus according to the 69th aspect, it is preferred that: if thereare a predetermined number of pixels or more pixels from which an edgehas been extracted are present around the defect area indicated by thedefect information for the reference image, the flat portion extractionunit does not extract the defect area as the flat portion area.

According to the 79th aspect of the invention, in the image processingapparatus according to the 78th aspect, it is preferred that: if an edgehas been extracted from a majority of pixels among pixels present in apredetermined area surrounding a pixel in the defective area, the flatportion extraction unit does not extract the pixel in the defect area asa pixel in the flat portion.

According to the 80th aspect of the invention, a computer-readablecomputer program product has an image processing program enabling acomputer to execute functions of the image processing apparatusaccording to any of the 1st through 79th aspects.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows the structure of an electronic camera that allows the useof exchangeable lenses;

FIG. 2 shows a block diagram of the electronic camera used inconjunction with a personal computer (PC) and peripheral apparatuses;

FIG. 3 shows the photographing procedure executed on the electroniccamera side in a first embodiment;

FIG. 4 illustrates local normalization processing executed on theluminance plane;

FIG. 5 shows a histogram of the transmittance map;

FIG. 6 presents a flowchart of the processing executed by the PC in thefirst embodiment;

FIG. 7 shows the photographing procedure executed on the electroniccamera side in a second embodiment;

FIG. 8 shows how the positions of a dust shadow may change as the pupilposition changes;

FIG. 9 shows how the size of a dust shadow may change as the F value,i.e., the aperture value, changes;

FIG. 10 shows one-dimensional filter coefficients each corresponding toa given aperture value;

FIG. 11 shows a filter used in transmittance map conversion with theaperture value set to F16, expressed as a two-dimensional filter;

FIG. 12 presents a flowchart of the processing executed by the PC in thesecond embodiment;

FIG. 13 shows how the transmittance is converted through F valueconversion at a position where dust in a medium size is present;

FIG. 14 shows the photographing procedure executed on the electroniccamera side in a third embodiment;

FIG. 15 presents a flowchart of the processing executed by the PC in thethird embodiment;

FIG. 16 shows an edge extraction filter;

FIG. 17 presents a flowchart of the processing executed by the PC in afourth embodiment;

FIG. 18 shows how the program may be provided in a recording medium suchas a CD-ROM or through a data signal on the Internet or the like; and

FIG. 19 illustrates the edge map peripheral assimilation processing.

BEST MODE FOR CARRYING OUT THE INVENTION First Embodiment

(Structures of Electronic Camera and Personal Computer)

FIG. 1 shows the structure of a single lens reflex electronic stillcamera (hereafter referred to as an electronic camera) that allows theuse of exchangeable lenses. The electronic camera 1 includes a camerabody 2 and a variable optical system 3 constituted with a mount-typeexchangeable lens. The variable optical system 3 includes a built-inlens 4 and a built-in aperture 5. While the lens 4 is constituted with aset of a plurality of optical lenses, a single representative lens isshown in the figure, and the position of the lens 4 is referred to as amain pupil position (hereafter simply referred to as a pupil position).The variable optical system 3 may be a zoom lens. The pupil position isindicated with a value determined in correspondence to the lens type orthe zoom position of the zoom lens. It may be affected by the focallength, as well.

The camera body 2 includes a shutter 6, optical components 7 such as anoptical filter and a cover glass, and an image sensor (image-capturingelement) 8. The variable optical system 3 can be attached/detachedfreely at a mount unit 9 of the camera body 2. In addition, the variableoptical system 3 transmits optical parameters such as informationrelated to the pupil position and information related to the aperturevalue to a control unit 17 (see FIG. 2) of the electronic camera 1 viathe mount unit 9. The aperture value may change within a range of, forinstance, F2.8 to F22.

Reference numeral 10 indicates dust having become adhered to the surfaceof an optical components 7 disposed to the front of the image sensor 8.The following two facts have been learned based upon the results oftests conducted by varying the aperture value and the pupil position atthe variable optical system 3 to evaluate changes occurring with respectto the dust shadows in the photographic image.

(1) The size of a dust shadow and the light transmittance change incorrespondence to the aperture value.

(2) The position of the dust is shifted as the lens pupil positionchanges.

These two facts having been learned through the tests indicate that dustsettled at a fixed position is photographed differently each time thephotographing conditions (aperture value and pupil position) set for thelens change. A method that may be adopted to eliminate the adverseeffect of dust in such a variable optical system is explained below.

FIG. 2 shows a block diagram of the electronic camera 1 used inconjunction with a PC (personal computer) 31 and peripheral apparatuses.The PC31, which functions as an image processing apparatus, executesdust effect elimination processing to be detailed later by obtainingimage data from the electronic camera 1.

The electronic camera 1 comprises the variable optical system 3, theoptical components 7, the shutter 6 (not shown in FIG. 2), the imagesensor 8, an analog signal processing unit 12, an A/D conversion unit13, a timing control unit 14, an image processing unit 15, an operationunit 16, the control unit 17, a memory 18, a compression/decompressionunit 19, a display image generating unit 20, a monitor 21, a memory cardinterface unit 22 and an external interface unit 23.

The image sensor 8 captures a subject image through the variable opticalsystem 3 and outputs image signals (image capturing signals)corresponding to the captured subject image. The image sensor 8 includesa rectangular image capturing area constituted with a plurality ofpixels and sequentially outputs analog image signals each correspondingto the electric charge having been stored at a specific pixel to theanalog signal processing unit 12 in units of individual pixels. Theimage sensor 8 may be constituted with, for instance, a singleplate-type color CCD. The analog signal processing unit 12 includes aninternal CDS (correlational double sampling) circuit, an internal AGC(of automatic-gain control) circuit and the like, and executes aspecific type of analog processing on the image signals input thereto.The A/D conversion unit 13 converts the analog signals having beenprocessed at the analog signal processing unit 12 to digital signals.The timing control unit 14, which is controlled by the control unit 17,controls the timing with which the image sensor 8, the analog signalprocessing unit 12, the A/D conversion unit 13 and the image processingunit 15 are individually engaged in operation.

The memory card interface unit 22 achieves interface with a memory card(a card-type removable memory) 30. The external interface unit 23achieves interface with an external apparatus such as the PC 31 via aspecific type of cable or a wireless transmission path. The operationunit 16 is equivalent to a shutter release button, a mode selectorbutton and the like. At the monitor 21, various menus, a subject imagecaptured with the image sensor 8 or an image reproduced based upon imagedata stored in the memory card is displayed. The output of the operationunit 16 is connected to the control unit 17, whereas the output of thedisplay image generating unit 20 is connected to the monitor 21. Theimage processing unit 15 may be constituted with, for instance, asingle-chip microprocessor dedicated to image processing.

The A/D conversion unit 13, the image processing unit 15, the controlunit 17, the memory 18, the compression/decompression unit 19, thedisplay image generating unit 20, the memory card interface unit 22 andthe external interface unit 23 are connected with one another via a bus24.

At the PC 31 to which a monitor 32, a printer 33 and the like areconnected, an application program recorded in a CD-ROM 34 ispreinstalled. In addition, the PC 31 includes a memory card interfaceunit (not shown) for achieving interface with the memory card 30 and anexternal interface unit (not shown) for achieving interface with anexternal apparatus such as the electronic camera 1 via a specific typeof cable or a wireless transmission path as well as a CPU, a memory anda hard disk (not shown).

As the operator of the electronic camera 1 structured as shown in FIG. 1selects a photographing mode and presses the shutter release button viathe operation unit 16, the control unit 17 implements timing control onthe image sensor 8, the analog signal processing unit 12 and the A/Dconversion unit 13 via the timing control unit 14. The image sensor 8generates image signals corresponding to an optical image formed at theimage capturing area by the variable optical system 3. The image signalsthen undergo a specific type of analog signal processing at the analogsignal processing unit 12 and are output to the A/D conversion unit 13as image signals having undergone the analog processing. The A/Dconversion unit 13 digitizes the analog image signals and provides theresulting image data to the image processing unit 15.

It is assumed that the image sensor 8 in the electronic camera 1achieved in the embodiment is a typical single-plate color image sensorhaving R (red), G (green) and B (blue) color filters disposed in a Bayerarray and that the image data provided to the image processing unit 15are expressed in the RGB colorimetric system. At each of the pixelsconstituting the image data, color information corresponding to a singlecolor component among R, G and B is present. In this document, the term“pixel” referring to each of the photoelectric conversion elementsconstituting the image sensor 8 is also used to refer to a single unitof image data corresponding to the pixel. In addition, the descriptionis given by adopting a concept that an image, too, is constituted withthe plurality of pixels.

The image processing unit 15 executes image processing such asinterpolation, gradation conversion and edge emphasis on such imagedata. The image data having undergone the image processing then undergoa specific type of compression processing at thecompression/decompression unit 19 as required and then are recorded intothe memory card 30 via the memory card interface unit 22. The image datahaving undergone the image processing may instead be directly recordedinto the memory card 30 without having any compression processingexecuted on them.

The image data having undergone the image processing are provided to thePC 31 via the memory card 30. They may be provided to the PC 31 via theexternal interface 23 and a specific type of cable or wirelesstransmission path, instead. It is assumed that following the imageprocessing, the image data will have undergone the interpolationprocessing, with color information corresponding to all the colorcomponents, R, G and B present at each pixel.

(Dust Effect Elimination Processing)

Next, an explanation is given on the processing executed on each set ofphotographic image data to eliminate the adverse effect of dust. In thefirst embodiment, a reference image used to obtain dust informationcorresponding to each optical photographing condition is photographedwith the electronic camera 1. However, the reference image is notconstituted with completely uniform white reference data but is obtainedby photographing, for instance, blue sky, a substantially uniform wallsurface, a gray chart or a solid paper surface. The reference data usedin the embodiment may contain limb darkening at the lens (vignetting),subject gradation, shading at the image sensor and the like. It isassumed that readily available reference data that can be obtained withease through a photographing operation performed at a convenientlocation are used, and the reference data do not need to be perfectlyuniform, since uniformity is achieved through conversion executed byusing an algorithm in the image processing.

(Operation Executed on Electronic Camera Side)

FIG. 3 shows the photographing procedure executed at the electroniccamera 1 in the first embodiment.

1) A regular photographing operation 101 is executed at a pupil positionP1 and an aperture value A1 and correction target image data 1 areoutput.

2) A uniform surface photographing operation 102 is then executed at thesame pupil position P1 and aperture value A1 and reference image data 1are output.

3) Next, a regular photographing operation 103 is executed by varyingthe pupil position and the aperture value to P2 and A2 respectively, andcorrection target image data 2 are output.

4) A uniform surface photographing operation 104 is then executed at thesame pupil position P2 and aperture value A2 as those set for theregular photographing operation 103, and reference image data 2 areoutput.

Namely, a photographing operation is first performed by holding theelectronic camera 1 toward the subject to be photographed (regularphotographing operation), and immediately afterward, the electroniccamera 1 is held toward the sky or a wall surface to photograph auniform surface (uniform surface photographing operation).Alternatively, the state of the camera may be sustained unchanged fromthat during the regular photographing operation and a sheet of whitepaper or a solid color paper may be held at a position severalcentimeters to 10 cm in front of the lens. Thus, a pair of photographingoperations, i.e., a regular photographing operation and a uniformsurface photographing operation, are performed. The description “imagedata are output” in this context refers to recording of the image datainto the memory card 30 or a direct output of the image data to the PC31 via the external interface 23.

Since there is a likelihood of the state of dust changing in theelectronic camera, the uniform surface is photographed immediately afterphotographing the correction target image under the same opticalconditions in the embodiment. However, the uniform surface actually doesnot need to be photographed immediately after the regular photographingoperation. As long as the same photographing conditions can be opticallyreplicated with regard to the pupil position and the aperture value,even uniform surface data obtained through a photographing operationperformed even a day or so later are often good enough for use since thestate of most dust is unlikely to have changed greatly. Accordingly, thedata obtained by replicating the same optical conditions and performinga photographing operation with a time lag small enough to sufficientlyreflect the dust information corresponding to the regular photographingoperation may be used as the uniform surface data. It is to be notedthat the order in which the regular photographing operation and theuniform surface photographing operation are performed may be reversed byfirst executing the uniform surface photographing operation and thenperforming the regular photographing operation.

(Operation Executed on Image Processing Apparatus Side)

Image data obtained through a photographing operation executed at theelectronic camera 1 first undergo the specific image processing and thenare provided to the PC 31. At the PC 31, dust effect eliminationprocessing is executed by using a pair of sets of data, i.e., a set ofcorrection target image data and a set of reference image data. The PC31may be regarded as an image processing apparatus that executes the dusteffect elimination processing. Both the reference image data and thecorrection target image data are input to the PC 31 after undergoingBayer array RGB interpolation processing. The reference image data andthe correction target image data explained below are obtained throughphotographing operations performed under identical optical conditions,i.e., at the same pupil position and the same aperture value. FIG. 6presents a flowchart of the processing executed at the PC 31.

(Processing on Reference Image Data)

1) Generation of Luminance Plane

In step S11 in FIG. 6, a luminance (or brightness) plane is generated. Aluminance signal is generated based upon the R, G and B signals by usingthe following expression (1) for each pixel [i,j] constituting thereference image data. [i,j] indicates the position of the specificpixel.Y[i,j]=(R[i,j]+2*G[i,j]+B[i,j])/4  (1)While the R, G and B planes may be individually analyzed, the adverseeffect of dust shadows basically manifests simply as signal attenuation,regardless of the color component. Accordingly, the R, G and B signalsare converted to a luminance component that enables effective use of allthe available information and can be used to reduce the adverse effectof random noise. In addition, since only the single luminance componentplane instead of the three planes, i.e., the R, G and B planes, needs tobe analyzed, the processing can be speeded up. The luminance componentgeneration ratios are not limited to those in the expression above andthey may be set to R:G:B=0.3:0.6:0.1 instead.2) Generation of Transmittance Map (Gain Map Extraction)

In step S12, a transmittance map is generated (gain map extraction) byexecuting the following processing.

2-1) Local Normalization Processing (Gain Extraction Processing)

As described earlier, the reference image data do not necessarilyachieve perfect uniformity. For this reason, the luminance plane havingbeen generated does not achieve perfect uniformity, either. Atransmittance signal T[i,j] is calculated as expressed in (2) below foreach of the pixels in such a luminance plane by locally normalizing(standardizing) the pixel value. Namely, the relative ratio of the valueindicated for the target pixel [i,j] and the average pixel value takenover a local range containing the pixel is calculated for each pixel.Through this processing, any non-uniformity such as gradation andshading contained in the uniform surface data is algorithmicallyeliminated in a desirable manner and, as a result, the extent to whichthe transmittance has been lowered due to a dust shadow alone can beextracted. The transmittance values over the entire image planedetermined as described above are referred to as a transmittance map(gain map). The transmittance map contains defect information indicatingdefects in the reference image. It is to be noted that a pixel value isa value indicated by a color signal (color information) corresponding toa specific color component or a luminance signal (luminance information)generated at each pixel. For instance, when the data are expressed withone byte, a pixel value assumes a value within a range of 0 to 255.$\begin{matrix}{{T\left\lbrack {i,j} \right\rbrack} = \frac{Y\left\lbrack {i,j} \right\rbrack}{{\left( {\sum\limits_{m = {i - a}}^{i + a}{\sum\limits_{n = {j - b}}^{j + b}{Y\left\lbrack {{i + m},{j + n}} \right\rbrack}}} \right)/\left( {{2a} + 1} \right)}\left( {{2b} + 1} \right)}} & (2)\end{matrix}$

The local average should be calculated over a range of (2a+1)×(2b+1)pixels, which ranges over an area greater than the size of the dust.Ideally, the local average should be calculated over a range having anarea approximately 3 times the area of the dust shadow to obtainaccurate transmittance data. “a” represents the number of pixelsdisposed to the left and to the right relative to the target pixel [i,j]and b represents the number of pixels disposed further upward anddownward relative to the target pixel [i,j]. For instance, assuming thatthe pixels are disposed with a 12 μm pitch at the image sensor 8 andthat the distance between the image-capturing surface and the surfacehaving the dust adhered thereto is 1.5 mm, the diameter of large sizedust is equivalent to approximately 15 pixels when photographed with theaperture value set to F22 and the diameter of the large dust equivalentto approximately 40 pixels with the aperture value set to F4.Accordingly, it is desirable to set both a and b to 40 so as to take thelocal average over an 81×81 pixel range. However, it is simply anexample, and the local average may be calculated over a pixel rangecontaining a number of pixels other than 81×81.

The extent to which dust shadows manifest is greatly dependent upon theaperture value, and the shadow of a very small dust mote disappears assoon as the aperture is opened. However, the shadow of a large dust motemay still occupy a large area although the shadow itself is lightenedeven when the aperture is set to the open side. Depending upon the pixelpitch width at the image sensor, around dust shadow ranging over severaltens of pixels may manifest even when the aperture is set to the openside. In such a case, it is necessary to calculate the local averageover a very large range. For this reason, the processing may be executedby using representative pixels selected through sub-sampling (culling)if the processing needs to be expedited.

The processing executed to calculate the relative ratio over the(2a+1)×(2b+1) pixel range is referred to as local normalizationprocessing (gain extraction processing) The filter used to calculate therelative ratio over the (2a+1)×(2b+1) pixel range may be referred to asa gain extraction kernel. FIG. 4 shows how the local normalizationprocessing is executed on the luminance plane. FIG. 4(a) shows theluminance signals at pixels disposed along the horizontal directionwithin the luminance plane, with reference numerals 41 and 42 indicatingthat the presence of dust has lowered luminance signal values. FIG. 4(b)shows the results of the local normalization processing described aboveexecuted on the luminance signals in FIG. 4(a). Namely, it shows theresults of the normalization processing executed on the pixel valuesover the local range. Reference numerals 43 and 44 respectivelycorrespond to reference numerals 41 and 42 in FIG. 4(a), each indicatingthe transmittance at a point at which dust is present. Nonuniformitysuch as gradation and shading contained in the uniform surface data isthus eliminated, and the extent to which the transmittance has beenlowered due to the dust shadows alone can be extracted. As a result, thepositions at which the dust is present and the specific levels oftransmittance at the individual positions can be ascertained at the sametime.

2-2) Low Pass Processing on Transmittance Map

While low pass processing on the transmittance map may be optional, itis more desirable to execute this processing since it is mostly highlyeffective. Since the transmittance signal T[i,j] contains random noiseattributable to the quantum fluctuation of the luminance signal, a dustshadow may be detected as mottling over an area where the transmittanceis at a level close to 1 and a subtle effect of the dust shadow remainsdue to the randomness of the noise, if the threshold valuedecision-making in 2-4 below is executed directly on the transmittancemap. The appearance of the image can be somewhat improved by groupingthe mottled dust shadow through low pass filter processing expressed asin (3) below.T[i,j]={4*T[i,j]+2*(T[i−1,j]+T[i+1,j]+T[i,j−1]+T[i,j+1])+1*(T[i−1,j−1]+T[i−1,j+1]+T[i+1,j−1]+T[i+1,j+1])}/16  (3)2-3) Statistical Analysis of Transmittance Map

Next, a statistical analysis is executed by calculating an average valueM as expressed in (4) below over the entire image plane of thetransmittance map obtained through the local normalization processingdescribed earlier and then calculating a standard deviation σ asexpressed in (5) below. It is to be noted that Nx and Ny respectivelyindicate the total numbers of pixels present along the x direction andthe y direction. $\begin{matrix}{M = {\frac{1}{N_{x}N_{y}}{\sum\limits_{i,j}{T\left\lbrack {i,j} \right\rbrack}}}} & (4) \\{\sigma = \sqrt{\frac{1}{N_{x}N_{y}}{\sum\limits_{i,j}\left( {{T\left\lbrack {i,j} \right\rbrack} - M} \right)^{2}}}} & (5)\end{matrix}$2-4) Threshold Value Decision-Making

The aerial ratio of dust signals in the transmittance map is basicallyvery small, and the results of the statistical analysis executed asdescribed in 2-3 reflect the evaluation of the random noise (shot noise)attributable to the quantum fluctuations of the transmittance signals.Reference numeral 46 in FIG. 4, which is an enlargement of an areaindicated with reference numeral 45, indicates manifestation of finerandom noise. A histogram of the transmittance map shows a normaldistribution of the standard deviation σ around the average value M (Mis a value very close to 1). FIG. 5 shows the histogram of thetransmittance map. Since the fluctuations in this range are consideredto be unaffected by the change in the transmittance attributable to dustshadows, the transmittance may be forcibly set to 1. Namely, thresholdvalue decision-making is executed in conformance to the conditionsexpressed in (6) and (7) belowif |T[i,j]−M|≦−3σ then T[i,j]=1  (6)else T[i,j]=T[i,j]  (7)

Since 99.7% of the normally distributed random data concentrate withinthe range of ±3σ, the effect of the random noise can be eliminated witha fair degree of accuracy by processing the data in this range. Anysignal indicating a transmittance value outside the ±3σ range, whichcannot be attributed to a statistical error, is an abnormal signalconsidered to indicate a phenomenon caused by a lowered transmittancedue to a dust shadow. If a dust shadow is present in such an abnormalarea, the transmittance normally indicates a value smaller than 1.

However, the transmittance may indicate a value greater than 1 althoughthis does not happen very often. Such a phenomenon is not due to a dustshadow and is observed when, for instance, interference fringes, whichmanifest as the incident light is intensified or attenuated, are inducedby a defect attributable to a stria (nonuniformity in the refractiveindex) of the optical low pass filter or the like. For this reason, themethod according to the present invention can be adopted to detect adefect other than dust present at an optical member disposed in theoptical path. In addition, the adverse effect of a defect at the pixelin the image sensor, too, can be detected through the method. While dustpresent at a position close to the image sensor 8 tends to appear withmore clarity without becoming blurred, even dust present on thephotographic lens, which is bound to appear fairly blurred in thephotographed image, can be detected with a high level of accuracy.

It is to be noted that the threshold value decision-making should beexecuted in conformance to the conditions expressed as in (8), (9) and(10) below if the adverse effect of dust shadows only needs to beeliminated.if |T[i,j]−M|≦−3σ then T[i,j]=1(8)else if T[i,j]>1T[i,j]=1  (9)else T[i,j]=T[i,j]  (10)

Since the average value M used in the decision-making always takes avalue close to 1, the value 1 may substitute for M.

Through the processing described above, two types of defect information,i.e., map information indicating defective pixel positions (obtained bymaking a decision as to whether or not T=1) and transmittanceinformation indicating the degree of each defect, can be obtained atonce. It is to be noted that the transmittance map described above,which indicates the local relative gains, may be alternatively referredto as a gain map.

Under normal circumstances, a defect such as the presence of dust isdetected by using a differential filter for edge detection. However,dust present within the optical path becomes optically blurred andmanifests as a dust shadow having extremely low contrast with thesurrounding area. In such a case, the sensitivity of the differentialfilter is often not even close to being high enough and the low contrastdust shadow can hardly be detected. By adopting the decision-makingmethod based upon the statistical characteristics of the transmittancedescribed above, an extremely high sensitivity dust detection is enabledand it becomes possible to correct the adverse effect of target dustpresent within the optical path.

(Processing on Correction Target Image)

3) Gain Correction

In step S13, gain correction is executed. The correction target imagedata are corrected by using the transmittance map having been obtainedthrough the method described above. The gain correction is executed byindividually multiplying the R, G and B values indicated in thecorrection target image data by the reciprocal of the transmittancesignal value as indicated in (11), (12) and (13) below.R[i,j]=R[i,j]/T[i,j]  (11)G[i,j]=G[i,j]/T[i,j]  (12)B[i,j]=B[i,j]/T[i,j]  (13)

Through the processing described above, the intensity lowered by dustshadows can be successfully corrected. In addition, since thetransmittance map undergoes the threshold value decision-making todetermine data that do not require correction, no superfluous correctionis executed. Namely, since the effect of the random noise is alreadyremoved from the transmittance T in an area free of dust, the noise inthe R, G and B signals is not amplified.

As described above, by adopting the first embodiment, it is possible tocorrect in a desirable manner an image that has been photographed at anytime point with a standard electronic camera that does not include aspecial mechanism for anti-dust measures. Since the uniform surfacephotographed to obtain the reference image does not need to achieveperfect uniformity, the uniform surface image can be obtained withrelative ease. Furthermore, compared to dust detection methods in therelated art, superior sensitivity is assured both in the detection andin the correction.

Second Embodiment

In the second embodiment, a single reference image photographed toobtain dust information is used for dust shadow removal in conjunctionwith a plurality of images photographed under varying opticalphotographing conditions. Since the structures of the electronic camera1 and the PC 31 functioning as the image processing apparatus areidentical to those in the first embodiment, their explanation isomitted.

(Operation Executed on Electronic Camera Side)

FIG. 7 shows the photographing procedure executed at the electroniccamera 1 in the second embodiment.

1) A uniform surface photographing operation 201 is executed at a pupilposition P0 and an aperture value A0 and reference image data 0 areoutput.

2) A regular photographing operation 202 is executed at a pupil positionP1 and an aperture value A1 and correction target image data 1 areoutput.

3) A regular photographing operation 203 is executed at a pupil positionP2 and an aperture value A2 and correction target image data 2 areoutput.

4) A regular photographing operation 204 is executed at a pupil positionP3 and an aperture value A3 and correction target image data 3 areoutput.

Namely, the electronic camera 1 is first held toward the sky or a wallsurface to photograph a uniform surface (uniform surface photographingoperation) and subsequently, a photographing operation is performed byholding the electronic camera 1 toward a subject to be photographed anytime (normal photographing operation).

It is assumed that the reference image is photographed at the aperturevalue A0 corresponding to a state in which the aperture opening isnarrowed to the greatest possible extent within the adjustment range ofthe variable optical system 3. In the case of a standard lens, theaperture value corresponding to the aperture opening being narrowed tothe greatest extent may be, for instance, approximately F22. Acorrection target image is photographed with the aperture value setequal to the aperture value when photographing the reference image orset to a value further toward the open side.

The uniform surface photographing operation does not need to berepeatedly performed as long as the state of the dust presence remainsunchanged. While it is naturally more desirable to perform a uniformsurface photographing operation as many times as possible, even dataobtained once a day can be normally effectively used as dust data. It isleft to the photographer's discretion as to whether or not to perform auniform surface photographing operation in a given situation. However,if a considerable length of time has elapsed since the most recentuniform surface photographing operation, the reference data having beenobtained through the uniform surface photographing operation may not bevery reliable. Accordingly, reference image data obtained through auniform surface photographing operation may be used only in conjunctionwith image data obtained through a regular photographing operationperformed within a predetermined length of time following the uniformsurface photographing operation. In addition, the uniform surfacephotographing operation does not need to be performed prior to a regularphotographing operation. Reference image data obtained by subsequentlyperforming a uniform surface photographing operation may be usedinstead. If the uniform surface photographing operation has beenperformed a plurality of times prior to and following a regularphotographing operation, the reference image data having been obtainedthrough the uniform surface photographing operation closest in time tothe regular photographing operation may be used. If there is alikelihood of new dust having become adhered recently, the referenceimage data having been obtained through the uniform surfacephotographing operation either the closest or the second closest in timeto the regular photographing operation prior to or following the regularphotographing operation may be selectively used.

(Operation Executed on Image Processing Apparatus Side)

It is assumed that pupil position and aperture value identification dataare embedded both in reference image data and target image data input tothe PC 31 functioning as the image processing apparatus. The pupilposition data may be obtained through calculation by using a conversiontable based upon a recorded data embedded in the photographic data,indicating the lens type, the zoom position and the focal pointposition. FIG. 12 presents a flowchart of the processing executed at thePC 31.

(Processing on Reference Image)

1) Generation of Luminance Plane and Generation of Transmittance Map

A luminance plane is generated in step S21 and a transmittance map isgenerated in step S22, as in the first embodiment.

2) Pupil Position Conversion of Transmittance Map

In step S23, pupil position conversion is executed for the transmittancemap. The pupil position conversion is executed so as to convert theposition of dust in the reference image to a dust position at which thedust is predicted to appear when viewed from the pupil position havingbeen assumed for the correction target image. FIG. 8 shows how theposition of a dust shadow changes as the pupil position changes. FIG.8(a) shows the relationship among the pupil position, dust and theimage-capturing surface at the image sensor 8. FIG. 8(b) shows how thechange in the pupil position causes the dust shadow to move on theimage-capturing surface.

As FIG. 8 clearly indicates, the position of a dust shadow appearing inthe image becomes shifted along the direction of the radius vector froman optical axis 51, i.e., from the center of the image, as the pupilposition is altered. Under such circumstances, there is estimated theextent Δr by which the position of a dust shadow present at a positiondistanced from the optical axis 51 by a distance r in the image becomesdisplaced along the direction of the radius vector. With P0 representingthe pupil position assumed when taking the reference image and P0′representing the pupil position assumed when taking the correctiontarget image and also assuming that dust is present at a positiondistanced from the image-capturing surface by a distance l, Δr can becalculated as expressed in (14) below. $\begin{matrix}{{\Delta\quad r} = {r \cdot \frac{l}{P_{0}^{\prime} - l} \cdot \frac{P_{0} - P_{0}^{\prime}}{P_{0}}}} & (14)\end{matrix}$It is to be noted that the distance l indicates a value obtained byconverting the thickness of the optical component to the length of theoptical path represented in the air.

By displacing the transmittance map T[i,j] corresponding to thereference image to [r′,θ] as expressed in (15) below on a polarcoordinate system [r,θ], the transmittance map is converted to atransmittance map T′[i,j] on the coordinates [i,j] $\begin{matrix}{r^{\prime} = {{r + {\Delta\quad r}} = {r\left( {1 + {\frac{l}{P_{0}^{\prime} - l} \cdot \frac{P_{0} - P_{0}^{\prime}}{P_{0}}}} \right)}}} & (15)\end{matrix}$

The extent of shift Δr increases as the distance from the optical axis51 increases. Depending upon the value of the pupil position, the shiftmay range over several tens of pixels in the peripheral area of anactual image.

3) F Value Conversion of Transmittance Map

In step S24, F value conversion of the transmittance map is executed. Ifthe aperture value set when photographing the reference image and theaperture value set when photographing the correction target image aredifferent from each other, the dust diameters and the transmittancevalues in the reference image are converted through the F valueconversion to dust diameters and transmittance values corresponding tothe aperture value set further on the open side to photograph thecorrection target image. FIG. 9 shows how the size of a dust shadowchanges as the F value, indicating the aperture value, changes. FIG.9(a) shows the dust shadow size corresponding to a large F value andFIG. 9(b) shows the dust shadow size corresponding to a small F value.As FIG. 9 clearly indicates, the following expression (16) is obtainedby applying the defining expression (F=focal length/effective apertureat lens) for the F value to the distance l between the image-capturingsurface and the position at which the dust is present and the range ofthe dust Γ both achieving similitude. $\begin{matrix}{\Gamma = \frac{l}{F}} & (16)\end{matrix}$

By dividing l by the pixel pitch a (mm/pixel) of the image sensor, thedust diameter can be indicated as a specific number of pixels. Thus, thepoint image dust is estimated to spread over a width Γ when the aperturevalue is indicated with an F value.

At the same time, since the dust shadow can be regarded to be spreadwith light uniformly irradiated on the point image dust with individualangles of incidence at the lens with the aperture opened within theaperture value, the distribution function of the point image can beassumed to have a completely uniform spread. Accordingly, the F valueconversion can be achieved through uniform low pass filter processing,the filter width Γ of which is expressed with a specific number ofpixels, to estimate the dust diameter and the transmittance with a highlevel of accuracy. While a circular non-separation type filter with adiameter Γ is normally used, a square separation type filter with alength Γ and a width Γ may be used instead to speed up the processing.

For instance, let us consider conversion of a transmittance map obtainedat F22when l=0.5 mm and a=5 μm/pixel to transmittance maps at F16, F11,F8, F5.6 and F4. The one-dimensional filter coefficients used at thesquare separation type filter are indicated as in FIG. 10. By using theone-dimensional filter coefficients listed in FIG. 10, the data arefiltered along the vertical direction and the horizontal direction. Itis to be noted that the one-dimensional filter coefficientscorresponding to the aperture value F16 include a total of sevencoefficients with coefficients 0.5 set at the two ends, so that the dustshadow spreading over an even number of pixels is filtered over an oddnumber range containing a uniform number of pixels present above, below,to the left and to the right around the target pixel. FIG. 11 shows theaperture value F16 filter expressed as a two-dimensional filter.

Through the conversion processing described above, the transmittance mapof the reference image is converted to a transmittance map with a pupilposition and an F value matching those of the correction target image.Namely, a transmittance map equivalent to the transmittance map thatwould be generated under optical conditions identical to those underwhich the correction target image is photographed is generated basedupon the transmittance map of the reference image.

(Processing on Correction Target Image)

3) Gain Correction

In step S25, gain correction is executed by using the transmittance mapresulting from the conversion processing described above. As in thefirst embodiment, the gain correction is executed by individuallymultiplying the R, G and B values indicated in the correction targetimage data by the reciprocal of the value indicated by the transmittancesignal having undergone the pupil position/F value conversion, asexpressed in (17), (18) and (19) below.R[i,j]=R[i,j]/T′[i,j]  (17)G[i,j]=G[i,j]/T′[i,j]  (18)B[i,j]=B[i,j]/T′[i,j]  (19)

FIG. 13 shows how the transmittance at a position where medium-size dustis converted through the F value conversion. The pixel position isindicated along the horizontal direction, whereas the transmittance isindicated along the vertical axis.

Once a single reference image is photographed at the smallest aperturevalue setting with the variable optical system, no more reference imageneeds to be photographed under different optical conditions. Namely,effective correction can be achieved by converting the dust data fromthe single reference image in correspondence to a specific correctiontarget image. As a result, the onus placed on the user of the electroniccamera is greatly reduced. In addition, as in the first embodiment, avery high level of sensitivity in dust detection is assured withoutrequiring photographing of a perfectly uniform image.

Third Embodiment

In the third embodiment, dust shadows in the correction target image aredetected and eliminated without using any uniform surface referenceimage. The method adopts a basic principle that once a flat area (localimage area over which the image is uniform) is found in the correctiontarget image, the dust transmittance map generation processing (gain mapextraction) executed on the reference image in the first embodiment canalso be executed in conjunction with the correction target image. Sincethe electronic camera 1 and the PC 31 functioning as the imageprocessing apparatus adopt structures similar to those in the firstembodiment, their explanation is omitted.

(Operation Executed on Electronic Camera Side)

FIG. 14 shows the photographing procedure executed at the electroniccamera 1 in the third embodiment.

1) A regular photographing operation 301 is executed at a pupil positionP1 and an aperture value A1 and correction target image data 1 areoutput.

2) A regular photographing operation 302 is executed at a pupil positionP2 and an aperture value A2 and correction target image data 2 areoutput.

3) A regular photographing operation 303 is executed at a pupil positionP3 and an aperture value A3 and correction target image data 3 areoutput.

4) A regular photographing operation 304 is executed at a pupil positionP4 and an aperture value A4 and correction target image data 4 areoutput.

Namely, in the third embodiment, no uniform surface photographingoperation is executed, unlike in the first embodiment and the secondembodiment.

(Operation Executed on Image Processing Apparatus Side)

(Processing on Correction Target Image)

FIG. 15 presents a flowchart of the processing executed at the PC 31functioning as the image processing apparatus. In step S31, a luminanceplane is generated. In step S32, an edge map is generated by executinggamma correction, edge extraction filter processing and threshold valuedecision-making on the luminance plane. In step S33, processing foradding dark areas to the edge map is executed. In step S34, processingfor enlarging the edge map is executed. In step S35, the edge map isconverted to a flat map. In step S36, self gain extraction processing isexecuted. In step S37, self gain correction processing is executed. Thefollowing is a detailed explanation of the individual processing steps.

1) Generation of Luminance Plane (Step S31)

The R, G and B signals are converted to a luminance signal Y for eachpixel [i,j] in the correction target image data. The conversion isexecuted through a method similar to that adopted in conjunction withthe reference image in the first embodiment.

2) Generation of Edge Map (Step S32)

An edge extraction filter is applied to the luminance plane to separateflat areas from edges within the correction target image. Dust presentwithin the optical path, which manifests as dust shadows with extremelylow contrast in the photographic image, often remains undetected by anedge extraction filter in the related art. Accordingly, one is allowedto assume that a great number of edge portions extracted through theedge extraction filter are not dust but actual edges in the image. Inorder to distinguish the edges in the image from the dust with an evenhigher level of accuracy, gradation correction processing is executedfirst on the luminance plane.

2-1) Gamma Correction of Luminance Plane

Let us assume that the correction target image expressed with lineargradation has been input and the luminance plane has been generated asdescribed above. Gradation conversion such as that expressed in (20)below is then executed on the luminance plane, with Y representing theinput signal (0=<Y=<Ymax) and Y′ representing the output signal(0=<Y′=<Y′max) in expression 20. It is to be noted that γ may assume avalue of 0.4, 0.5, 0.6 or the like. $\begin{matrix}{Y^{\prime} = {Y_{\max}^{\prime}\left( \frac{Y}{Y_{\max}} \right)}^{\gamma}} & (20)\end{matrix}$

Through this conversion processing, the contrast of intermediate toneson the lower intensity side is raised and the contrast on the higherintensity side is lowered. Namely, since a dust shadow tends to be lessnoticeable in a dark image area and tends to be more noticeable in abright image area, the contrast of the dust shadows is lowered throughthis conversion, whereas the relative contrast of normal image edges,which are primarily distributed in the mid tone ranges is raised throughthe conversion. As a result, a high level of separation is achieved withregard to the contrast of dust shadows and the contrast of normal edges.In addition, it is most desirable to set γ to 0.5 based upon the law ofpropagation of errors, in order to ensure that the converted data allowuniform handling of the shot noise attributable to quantum fluctuationof Y′ over the full gradation range. It is to be noted that expression(20) above is a power function. When γ=0.5, the power function is asquare root function.

If the input image has already undergone gamma correction processing inpreparation for the final output and the gamma correction processinghaving been executed is similar to the conversion described above, theprocessing may be skipped. In addition, by executing the processingafter first restoring the image to a linear gradation image throughinverse gamma correction, a higher level of separation is achieved.

2-2) Edge Extraction Filter Processing

Next, the edge extraction filter is applied to the luminance planehaving undergone the gamma correction, as shown in FIG. 16 and expressedin (21) below. YH[i,j] represents the edge extraction component at eachpixel.YH[i,j]={|Y′[i−1,j]−Y′[i,j]|+|Y′[i+1,j]−Y′[i,j]|+|Y′[i,j−1]−Y′[i,j]|+|Y′[i,j+1]−Y′[i,j]|+|Y′[i−1,j−1]−Y′[i,j]|+|Y′[i+1,j+1]−Y′[i,j]|+|Y′[i−1,j+1]−Y′[i,j]|+|Y′[i+1,j−1]−Y′[i,j]|+|Y′[i−2,j−1]−Y′[i,j]1+|Y′[i+2,j+1]−Y′[i,j]|+|Y′[i−2,j+1]−Y′[i,j]1+|Y′[i+2,j−1]−Y′[i,j]|+|Y′[i−1,j−2]−Y′[i,j]|+|Y′[i+1,j+2]−Y′[i,j]|+|Y′[i−1,j+2]−Y′[i,j]|+|Y′[i+1,j−2]−Y′[i,j]|+|Y′[i−3,j]−Y′[i,j]|+|Y′[i+3,j]−Y′[i,j]|+|Y′[i,j−3]−Y′[i,j]|+|Y′[i,j+3]−Y′[i,j]|+|Y′[i−3,j−3]−Y′[i,j]1+|Y′[i+3,j+3]−Y′[i,j]|+|Y′[i−3,j+3]−Y′[i,j]|+|Y′[i+3,j−3]−Y′[i,j]|}/24  (21)

The filter is designed to evenly collect data indicating absolute valuedifferences representing a plurality of correlational distances from alldirections so as to extract all the edges in the original image.

2-3) Threshold Value Decision-Making

By using expressions (22) and (23) below, the threshold valuedecision-making is executed on the edge extraction component YH toclassify it as an edge portion or a flat portion, and the results of thedecision are output to an edge map EDGE[i,j]. A threshold value Th1assumes a value of approximately 1 to 5 in conjunction with the 255gradations. Even if a dust shadow is present on an edge portion, thedust shadow is basically buried within a signal vibrating at the edgeportion and thus, no dust shadow elimination processing needs to beexecuted over the area.if YH[i,j]>Th1 EDGE[i,j]=1 (edge portion)  (22)else EDGE[i,j]=0 (flat portion)  (23)

As described above, weighting on the various gradation levels isadjusted through the gradation conversion executed as described in 2-1)and then the threshold value decision-making is executed by using aconstant threshold value Th1 over the entire gradation range, asdisclosed in 2-1). However, substantially similar effects can beachieved by extracting edges in the image expressed with the initiallinear gradations and executing threshold value decision-making withthreshold values set in correspondence to specific luminance levels,instead.

3) Addition of Dark Areas to Edge Map (Step S33)

The edge map indicates areas that should not undergo gain mapextraction. It is not desirable to execute the gain map extraction ondark areas as well as edge areas. Since the S/N ratio is poor in a darkarea, the reliability of the relative gain extracted from the dark areawould be low. In addition, since a dust shadow present on the dark areais hardly noticeable, it is not necessary to execute dust shadowelimination processing. Accordingly, dark areas, too, are added to theedge map as expressed in (24) below. A threshold value Th2 should be setto a value of 20 or smaller in conjunction with the 255 lineargradations. A schematic description “EDGE′=EDGE+DARK” may facilitateunderstanding of this operation.if Y[i,j]=<Th2 EDGE[i,j]=1  (24)4) Edge Map Enlargement Processing (Step S34)

As in the first embodiment, a transmittance map is generated bycomparing the relative ratio of the value at the central pixel among the(2a+1)×(2b+1) pixels and the average value within a flat area.Accordingly (2a+1)×(2b+1) pixel range enlargement processing is executedin advance, as expressed in (25) below for edge portions so as toexclude the edge portions from the kernel. It is to be noted that m=1,2, . . . a and that n=1, 2, . . . b.if EDGE[i,j]=1 EDGE[i±m,j±n]=1  (25)5) Conversion to Flat Map (Step S35)

The edge map EDGE[i,j] is converted to a flat map FLAT[i,j] as expressedin (26) and (27) below. This conversion is achieved through bitinversion. A flat area indicated in the flat map represents an areawhere self gain extraction may be executed in the correction targetimage by using the gain map extraction kernel constituted with(2a+1)×(2b+1) pixels.if EDGE[i,j]=0 FLAT[i,j]=1(flat portion)  (26)else FLAT[i,j]=0(edge portion)  (27)6) Self Gain Extraction (Step S36)

The processing for generating the transmittance map based upon thereference image data executed in the first embodiment is executed onlyfor areas where FLAT[i,j]=1.

6-1) Local Normalization Processing (Gain Extraction Processing)

Based upon the relative ratio within the (2a+1)×(2b+1) pixel range,T[i,j] in each area where FLAT[i,j]=1 is generated. T[i,j] is invariablyset to 1 in all the areas where FLAT[i,j]=0.

6-2) Statistical Analysis of Transmittance Map

Statistical analysis of T[i,j] in each area where FLAT[i,j]=1 isexecuted as in the first embodiment to calculate an average value m anda standard deviation σ.

6-3) Threshold Value Decision-Making

Threshold value decision-making is executed as in the first embodimentwith regard to T[i,j] within each area where FLAT[i,j]=1, and T[i,j] isset to 1 if it takes a value of m±3σ.

7) Self Gain Correction (Step S37)

Self gain correction is executed by multiplying the individual R, G andB values in the correction target image with the reciprocal of the valueindicated by the transmittance signal T [i, j] obtained through the selfextraction, as in the first embodiment.

Thus, even without any uniform surface reference image data, dustshadows in the correction target image itself can be extracted throughself extraction and be corrected. Namely, each area within a givenphotographic image that satisfies predetermined conditions to assurethat the area is flat is extracted. The extracted area is used both as areference image and a correction target image. In addition, it is notnecessary to take into consideration the effect attributable to thevariable optical system in the third embodiment. It is particularlyeffective when eliminating a great number of small dust shadows.

Fourth Embodiment

While the fourth embodiment is similar to the second embodiment in thatinformation related to dust positions obtained by photographing a singlereference image is used, a transmittance map is obtained in the fourthembodiment through self extraction executed on the correction targetimage itself, as in the third embodiment, instead of generating atransmittance map from the reference image. While the transmittance mapundergoes the pupil position conversion in the second embodiment, anerror may occur in the pupil position conversion if a value indicatingthe pupil position is an approximate value instead of the exact value.In the third embodiment, on the other hand, dust with a significant sizemay be extracted as an edge in the edge map extraction and be leftuncorrected. The fourth embodiment addresses such problems of the secondembodiment and the third embodiment. Namely, it adopts the highlyreliable transmittance map generation method achieved in the thirdembodiment and, at the same time, highly reliable dust positioninformation obtained as in the second embodiment is used for correction.It is to be noted that since the electronic camera 1 and the PC 31functioning as the image processing apparatus adopt structures identicalto those in the first embodiment, their explanation is omitted.

(Operation Executed on Electronic Camera Side)

The photographing procedure is similar to that executed in the secondembodiment.

(Operation Executed on Image Processing Apparatus Side)

FIG. 17 presents a flowchart of the processing executed at the PC 31functioning as the image processing apparatus.

(Processing on Reference Image)

1) A luminance plane is generated in step S41, as in the firstembodiment and the second embodiment.

2) A transmittance map is generated (gain map extraction) in step S42,as in the first embodiment and the second embodiment.

3) Pupil position conversion for the transmittance map is executed instep S43, as in the second embodiment.

4) F value conversion for the transmittance map is executed in step S44,as in the second embodiment.

5) Threshold value decision-making on transmittance map

In step S45, threshold value decision-making is executed on thetransmittance map. Following the F value conversion executed on thetransmittance map, dust shadows will have almost disappeared through thelow pass filter processing and transmittance values close to 1 will beindicated for a large number of pixels. In order to distinguish suchnearly invisible dust shadows from distinct dust shadows, thresholdvalue decision-making is executed again, as expressed in (28) and (29).For this decision-making, the standard deviation value C having beencalculated in the “transmittance map generation” step in 2) is reused.T′[i,j] represents the transmittance map having undergone the pupilposition conversion and the F value conversion.if |T′[i,j]−1|=<3σ then T′[i,j]=1  (28)else T′[i,j]=T′[i,j]  (29)6) Conversion to Dust Map

In step S46, the transmittance map is converted to dust map dmap [i,j]by binarizing the transmittance map as expressed in (30) and (31) below.if T′[i,j]<1 dmap[i,j]=1  (30)else dmap[i,j]=0  (31)

The decision-making executed as expressed in (30) may instead beexecuted by making a decision as to whether or not T′[i,j] is smallerthan 0.95 so as to allow a slightly greater margin.

7) Dust Map Enlargement Processing

In step S47, a dust map containing dust shadows in areas falling withinan allowable error range is created by enlarging the dust map asexpressed in (32) below by an extent corresponding to the error expectedto have manifested as a result of the pupil position conversion. In thisexample, an error, the extent of which corresponds to 3 pixels, forinstance, is assumed. It is to be noted that m=1, 2, 3, and that n=1, 2,3.if dmap[i,j]=1 dmap[i±m,j±n]=1  (32)

(Processing on Correction Target Image)

1) A luminance plane is generated in step S51, as in the thirdembodiment.

2) An edge map is generated in step S52, as in the third embodiment.

3) Processing for adding dark areas in the edge map is executed in stepS53, as in the third embodiment. A schematic description“EDGE′=EDGE+DARK” may facilitate understanding of this operation.

4) Excluding dust areas from edge map

In step S54, dust areas are excluded from the edge map. While a majorityof dust shadows are not extracted as edges due to their low contrast,shadows of large dust motes may have high contrast, and in such a case,they may be extracted as edges. In particular, if the correction targetimage is photographed by narrowing the aperture, a plurality of dustshadows may be extracted as edges. In order to ensure that these dustshadows are also specified as gain extraction areas instead of beingregarded as edge areas, the dust positions are forcibly separated fromthe actual edge portions, as expressed in (33) below by using the dustmap information having been obtained in step S46. Since it is notdesirable to remove too much edge area data, the dust map yet to undergothe dust map enlargement processing in step S47 is used for thesepurposes. A schematic description “EDGE′′=EDGE+DARK−DUST” may facilitateunderstanding of this operation.if dmap[i,j]=1 EDGE[i,j]=0  (33)4′) Edge map peripheral assimilation processing (correction of clippeddust areas) (S 60)

Since it is unnatural to leave the edge map with dust areas unevenlyclipped out (excluded), peripheral assimilation processing is executedwithin the edge map. For instance, as long as the background in theimage is uniform, e.g., blue sky, no problem arises if portions withdust of significant size having been extracted as edge portions areclipped out from the edge map by using the dust map information obtainedin step S46. Rather, they need to be clipped out. However, if portionsindicated in the dust map information obtained in step S46 to have dustpresent thereat in an image containing a patterned or structuredbackground are clipped out from the edge map, unnatural correctionprocessing is bound to be executed based upon the relationship to theactual peripheral pattern or texture. Accordingly, if it is decided thatthere are a large number of edge pixels around a pixel having beendetermined to be a non-edge pixel, the pixel is reassigned as an edgeportion.

The edge map peripheral assimilation processing is executed as describedbelow. More specifically, if more than four pixels, for instance, amongthe 8 marginal pixels (the filled pixels in FIG. 19, which only showsthe fourth quadrant relative to the target pixel [i,j]=[0,0]) of thetarget pixel shown in FIG. 19 are edge pixels, the target pixel, too, isdetermined to be an edge pixel. When more than four marginal pixels areedge pixels, a majority of the marginal pixels are edge pixels. In otherwords, if a majority of the marginal pixels are edge pixels, the targetpixel, too, is determined to be an edge pixel. It is to be noted thatwhile the eighth pixels relative to the target pixel on the horizontaldirection and the vertical direction are checked in the processingexpress below, marginal pixels do not need to be the eighth pixelsrelative to the target pixel. Pixels distanced from the target pixel byseveral pixels or 10 plus pixels may be checked as the marginal pixels.In addition, the following processing may be executed for all thepixels, or it may be executed only for pixels having indicated the value1 for dmap[i,j] and having been clipped out from the edge map. Data copyfor each pixel [i,j] tmp[i,j]=EDGE[i,j] Peripheral assimilationprocessing if tmp[i,j]=0{ sum =tmp[i−8,j]+tmp[i+8,j]+tmp[i,j−8]+tmp[i,j+8]+tmp[i−8,j−8]+tmp[i+8,j+8]+tmp[i−8,j+8]+tmp[i+8,j−8] if sum>4EDGE[i,j]=1 }5) The edge map enlargement processing is executed in step S55 as in thethird embodiment.6) The edge map is converted to a flat map in step S56 as in the thirdembodiment.7) Identification of self gain extraction areas

In step S57, self gain extraction areas are identified. In order toprevent erroneous correction of the correction target image, it is mostreasonable to eliminate the dust shadows only in areas identified asflat areas with dust present. Accordingly, area information indicatingareas satisfying these two requirements, i.e., an area that is flat andhas dust present, is obtained as expressed in (34) below, and theinformation thus obtained is then used for substitution in the flat map.Namely, only when a flag with a value 1 is set for both FLAT and dmap,FLAT=1, and otherwise FLAT=0.FLAT[i,j]=FLAT[i,j]*dmap[i,j]  (34)8) Self gain extraction

Unlike in the third embodiment, local normalization processing (gainextraction processing) alone is executed in the self gain extractionexecuted in step S58. No dust area limit processing through statisticalanalysis of the transmittance map and threshold value processing needsto be executed following the local normalization processing, since thegain extraction areas have already been narrowed down to areas arounddust through the processing in 7). The local normalization processing(gain extraction processing) is executed as in the third embodiment.Thus, dust search is executed by expanding each gain extraction areasurrounding the dust to an extent corresponding to the error in thepupil position conversion through the processing executed in step S47,so as to extract all the dust shadows without fail.

At this time, low pass processing is executed on the transmittance maphaving undergone the self extraction. Low pass processing similar tothat executed in the first embodiment is executed for each area havingundergone the self extraction of T[i, j] so as to remove the fluctuationcomponent at the pixel [i,j] contained in T[i,j]. In the embodiment, theself gain correction is executed through the self gain extraction onlyon local areas with dust present without executing any threshold valueprocessing based upon statistical analysis, and for this reason, the lowpass processing plays a crucial role. Namely, since the pixel value andthe transmittance value T[i,j] prior to the low pass processingfluctuate along the same direction, the local area will tend to take ona flat appearance if the self gain correction is executed as describedlater without first executing the low pass processing. Accordingly, byeliminating the fluctuation component from T[i, j], the pixel value canretain its fluctuation component so as to sustain dot continuity withthe surrounding area. This proves to be highly effective particularlywhen correcting a noisy image such as a high sensitivity image. A lowpass filter used in this step may be designed to have a slightly higherlevel of filtering strength compared to that used in the firstembodiment. In addition, the low pass filter processing of large dustareas (areas showing T[i,j] values considerably smaller than 1) whichtend to be readily affected by the low pass filter processing may beskipped.

9) Self gain correction

The self gain correction executed in step S59 is similar to thatexecuted in the third embodiment. Since dust transmittance informationis extracted from the correction target image itself, a cleancorrection, completely free of displacement is enabled even if theaccuracy of the pupil position conversion executed on the transmittancemap of the reference image is poor. It is to be noted that the self gainextraction is executed only for the self gain extraction areas havingbeen identified in step S57. Accordingly, the correction processing,too, is executed over these ranges alone, resulting in a reduction inthe processing load.

As described above, the fourth embodiment, in which the dust mapinformation corresponding to the reference image is effectivelyutilized, dust shadows of all sizes, from a dust shadow ranging over asignificant area to the shadow of a minuscule mote of dust, within thecorrection target image can be extracted in the self extractionprocessing without fail. In addition, when the accuracy of the pupilposition conversion executed for the reference image transmittance mapis poor, the fourth embodiment may be adopted as an alternative to thesecond embodiment. Also, as in the second embodiment, only a very smallworkload is placed on the photographer when photographing the referenceimage, as in the second embodiment.

With the image processing apparatus achieved in any of the first tofourth embodiments described above, defects such as black spots causedby dust or the like in an image photographed at a given operating timepoint under given operating conditions with an electronic camera can becorrected in a desirable manner and, as a result, a high quality imagecan be reproduced.

It is to be noted that while in the first, second and fourth embodimentsdescribed above, the photographer photographs an image considered to bealmost uniform as the reference image in order to create a transmittancemap and the transmittance map is generated through local normalizationprocessing and the like executed on the photographed reference image.However, the subject to be photographed as the reference image, which issubstantially uniform in the photographer's opinion, may actuallycontain small patterns or the like. In such a case, the reference imageshould be photographed basically by defocusing the subject. Forinstance, a sheet of paper being photographed to obtain the referenceimage may be photographed by placing it at a position closer to thecamera than the minimum photographing distance of the lens. Even ifsmall patterns are present, by defocusing the image so that the patternschange very gently over a range greater than the (2a+1)×(2b+1)-pixelgain extraction kernel, a highly usable, substantially uniform referenceimage can be obtained.

In addition, in the fourth embodiment, self gain extraction areas areidentified in step S57 and the correction is executed over theidentified ranges in step S58. This aspect of the fourth embodiment,narrowing down the correction ranges to ranges around dust (surroundingareas), may be adopted in the first to third embodiments, as well. Ifadopted in the first to third embodiments, the presence of dust shouldbe detected by using the transmittance map having been generated andthen the surrounding areas around the dust should be determined.

An explanation has been given with regard to the third embodiment onprocessing through which a single photographic image is obtained and adust map is generated by extracting flat areas in the photographicimage. However, if dust of a considerable size is present in a flatarea, the area may not be extracted as a flat area. While this problemis addressed in the fourth embodiment by obtaining a reference image, aflat area containing dust of a significant size can also be recognizedas a flat area for which defect information needs to be generated, basedupon a correlation among a plurality of images without having to obtaina reference image. For instance, if an image area that is alwaysdetected in the edge extraction at the same position in a plurality ofphotographic images obtained by photographing different subjects, thedetected image is highly likely to be an image of dust. Accordingly, anAND operation may be executed for a plurality of photographic imagescorresponding to edge map, which is processed as explained in referenceto the third embodiment, and an area over which AND relationship is trueamong the plurality of images should be eliminated from the edge map.The AND area can then be added as a flat area, thereby making itpossible to prepare a transmittance map even when dust of a considerablesize is present. It is to be noted that an AND operation may be executedfor data other than the edge map. The operation may be executed inconjunction with any data as long as they are generated based upon aphotographic image and enable detection of dust on the photographicoptical path through an AND operation executed for a plurality ofphotographic images. For instance, regardless of whether or notindividual image areas are flat areas, the gain extraction kernel-basedtransmittance map may be forcibly generated for the entire image plane,and an AND operation may be executed so that if there is an image areaextracted with similar transmittance rates at similar positions in aplurality of images, the image area is retained in the transmittance mapto be used as defect information with the other image areas excludedfrom the defect information.

By executing an OR operation on a plurality of photographic images withrespect to the transmittance map obtained over a flat area in the thirdembodiment, a transmittance map covering the entire photographic imageplane can be created. The positions of the flat areas detected as in thethird embodiment in the photographic image plane change incorrespondence to different photographic subjects. The results of the ORoperation of these flat areas may cover the entire photographic imageplane. Accordingly, it is possible to obtain a transmittance map for theentire photographic image plane by using a plurality of photographicimages, i.e., a plurality of correction target images, without having tophotograph a special reference image to obtain dust information. Thetransmittance map for the entire photographic image plane can be used asa common transmittance map for the plurality of correction targetimages.

It is to be noted that when executing an AND operation on a plurality ofphotographic images corresponding to an edge map or when executing an ORoperation on a plurality of photographic images to create atransmittance map as described above, the pupil positions and the Fvalues (aperture values) of the individual photographic images may notmatch. In such a case, pupil position conversion and F value conversionshould be executed on image signals or on transmittance map, as has beenexplained in reference to the second embodiment.

In addition, while an explanation is given above in reference to theembodiments on an example in which the present invention is adopted inconjunction with a Bayer array RGB calorimetric system, it goes withoutsaying that the present invention may be adopted in conjunction with anycolor filter array, as long as the data ultimately undergo interpolationprocessing. The present invention may also be adopted with equaleffectiveness in conjunction with other calorimetric systems (e.g., acomplementary color calorimetric system).

Furthermore, while an explanation is given above in reference to theembodiments on an example in which the present invention is adopted in asingle lens reflex electronic still camera that allows the use ofexchangeable lenses, the present invention is not limited to thisexample. The present invention may be, for instance, adopted in camerasthat do not allow the use of exchangeable lenses. The pupil position andthe aperture value of the lens can be ascertained as necessary through amethod in the known art.

While an explanation is given above in reference to the embodiments onan example in which image data obtained through a photographingoperation executed in the electronic still camera 1 are processed, thepresent invention is not limited to this example. The present inventionmay be adopted to process image data photographed with a video camerawhich handles dynamic images. In addition, the present invention may beadopted to process image data photographed with a portable telephoneequipped with a camera or the like. It may also be adopted in copiersand scanners as well. In other words, the present invention may beadopted to process all types of image data captured with image sensors.

While an explanation is given above in reference to the embodiments onan example in which the adverse effect of dust is eliminated throughprocessing executed at the PC (personal computer) 31 on image datahaving been photographed with the electronic camera 1, the presentinvention is not limited to this example. A program that enables suchprocessing may be installed in the electronic camera 1. Such a programmay instead be installed in a printer, a projector or the like as well.In other words, the present invention may be adopted in all types ofapparatuses that handle image data.

The program executed at the PC 31 may be provided in a recording mediumsuch as a CD-ROM or through a data signal on the Internet or the like.FIG. 18 shows how this may be achieved. The PC 31 receives the programvia a CD-ROM 34. In addition, the PC 31 is capable of achieving aconnection with a communication line 401. A computer 402 is a servercomputer that provides the program stored in a recording medium such asa hard disk 403. The communication line 401 may be a communicationnetwork for Internet communication, personal computer communication orthe like, or it may be a dedicated communication line. The computer 402reads out the program from the hard disk 403 and transmits the programthus read out to the PC 31 via the communication line 401. Namely, theprogram embodied as a data signal on a carrier wave is transmitted viathe communication line 401. Thus, the program can be distributed as acomputer-readable computer program product adopting any of various modesincluding a recording medium and a carrier wave.

While the invention has been particularly shown and described withrespect to preferred embodiments and variations thereof by referring tothe attached drawings, the present invention is not limited to theseexamples and it will be understood by those skilled in the art thatvarious changes in form and detail may be made therein without departingfrom the spirit, scope and teaching of the invention.

1. An image processing apparatus comprising: an image obtaining unit that obtains an image captured with an image sensor; and a defect information generating unit that generates defect information indicating a defect within the image having been obtained, based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel, wherein: the image sensor captures an image through an optical system; and the defect information is information on a projected image of a defect within an optical path, which manifests in the image.
 2. (canceled)
 3. (canceled)
 4. An image processing apparatus comprising: an image obtaining unit that obtains an image captured with an image sensor; a defect information generating unit that generates defect information indicating a defect within the image having been obtained, based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel; and a correction unit that corrects the defect within the image based upon the defect information, wherein: the correction unit determines a correction value by using an initial signal value indicated at a correction target pixel position.
 5. An image processing apparatus comprising: an image obtaining unit that obtains an image captured with an image sensor; a defect information generating unit that generates defect information indicating a defect within the image having been obtained, based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel; and a correction unit that corrects the defect within the image based upon the defect information, wherein: the defect information generating unit includes a relative ratio calculation unit that calculates a relative ratio of the value at the target pixel and the average value of the plurality of pixel values corresponding to the pixels present within the predetermined range containing the target pixel, and generates the defect information based upon the calculated relative ratio; and the correction unit corrects the defect by multiplying a value at a corresponding pixel by a reciprocal of the relative ratio.
 6. An image processing apparatus comprising: an image obtaining unit that obtains an image captured with an image sensor; and a defect information generating unit that generates defect information indicating a defect within the image having been obtained, based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel, wherein: the image obtaining unit obtains a plurality of images captured with the image sensor; and the defect information generating unit generates defect information indicating a defect within one of the plurality of images by using the plurality of images having been obtained.
 7. An image processing apparatus comprising: an image obtaining unit that obtains an image captured with an image sensor; and a defect information generating unit that generates defect information indicating a defect within the image having been obtained, based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel, wherein: the image obtaining unit obtains a plurality of images captured with the image sensor; and the defect information generating unit generates defect information corresponding to an entire image of each of the plurality of images by using the plurality of images having been obtained.
 8. An image processing apparatus comprising: an image obtaining unit that obtains a reference image photographed through an optical system; and a defect information generating unit that generates defect information indicating a defect within the reference image having been obtained, based upon a value of a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel in the reference image, wherein: the defect information is information on a projected image of a defect within an optical path, which manifests in the image.
 9. An image processing apparatus comprising: an image obtaining unit that obtains a reference image photographed through an optical system; and a defect information generating unit that generates defect information indicating a defect within the reference image having been obtained, based upon a value of a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel in the reference image, wherein: the defect information generating unit includes a relative ratio calculation unit that calculates a relative ratio of the value at the target pixel and the average value of the plurality of pixel values corresponding to the pixels present within the predetermined range containing the target pixel, and generates the defect information based upon the calculated relative ratio; the image obtaining unit obtains a correction target image photographed through the optical system; there is further provided a correction unit that corrects a defect within the correction target image based upon the defect information within the reference image; and the correction unit corrects a value of a corresponding pixel in the correction target image by multiplying the value of the corresponding pixel with a reciprocal of the relative ratio calculated for the reference image.
 10. An image processing apparatus comprising: an image obtaining unit that obtains a reference image photographed through an optical system; a defect information generating unit that generates defect information indicating a defect within the reference image having been obtained, based upon a value of a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel in the reference image, wherein: the image obtaining unit obtains a correction target image photographed through the optical system; there is further provided a correction unit that corrects a defect within the correction target image based upon the defect information within the reference image; and the correction unit determines a correction value by using an initial signal value indicated at a specific correction target pixel position.
 11. An image processing apparatus according to claim 9, wherein: if the reference image and the correction target image have been photographed through an optical system in substantially identical optical conditions with regard to an aperture value and a pupil position, the correction unit corrects a value at a pixel constituting the correction target image by directly using the defect information having been generated.
 12. An image processing apparatus according to claim 9, further comprising: a defect information conversion unit that converts the defect information in correspondence to at least either of an aperture value and a pupil position constituting optical conditions of the optical system, wherein: if the reference image and the correction target image have been photographed through the optical system under different optical conditions with regard to at least either the aperture value or the pupil position, the correction unit corrects a value at a pixel constituting the correction target image by using the converted defect information.
 13. (canceled)
 14. (canceled)
 15. (canceled)
 16. An image processing apparatus comprising: an image obtaining unit that obtains a reference image photographed through an optical system; and a defect information generating unit that generates defect information indicating a defect within the reference image having been obtained, based upon a value of a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel in the reference image, wherein: the predetermined range containing the target pixel is greater than a defect area manifesting within the reference image.
 17. An image processing apparatus according to claim 10, wherein: the image obtaining unit obtains a reference image photographed within a predetermined period of time preceding or following a time point at which the correction target image is photographed.
 18. An image processing apparatus according to claim 17, wherein: the image obtaining unit obtains a reference image photographed at a time point closest to or second closest to a time point at which the correction target image is photographed.
 19. An image processing apparatus comprising: an image obtaining unit that obtains an image captured by using an image sensor capable of separating light into a plurality of colors; a luminance signal generating unit that generates a luminance signal based upon signals of the plurality of colors constituting the image; a defect information generating unit that generates defect information indicating a defect within the image based upon the luminance signal for the image having been generated; and a correction unit that corrects a value corresponding to a color component at a defective pixel within the image by using the defect information.
 20. (canceled)
 21. An image processing apparatus according to claim 19, further comprising: a defect information generating unit that generates defect information indicating a defect within the image having been obtained based upon a value indicated by the luminance signal generated for a target pixel and an average value among values indicated by luminance signals generated for a plurality of pixels within a predetermined range containing the target pixel.
 22. An image processing apparatus according to claim 21, wherein: the defect information generating unit includes a relative ratio calculation unit that calculates a relative ratio of the value indicated by the luminance signal generated for the target pixel and the average value of the luminance signals generated for the plurality of pixels within the predetermined range containing the target pixel, and generates the defect information based upon the relative ratio having been calculated.
 23. An image processing apparatus according to claim 21, further comprising: a correction unit that corrects a value corresponding to a color component at a corresponding pixel by multiplying the value by a reciprocal of the relative ratio.
 24. (canceled)
 25. (canceled)
 26. (canceled)
 27. An image processing apparatus according to claim 1, wherein: the defect information generating unit simultaneously generates information indicating a position of the projected image of the defect within the optical path and information indicating intensity of the projected image of the defect within the optical path and records the position information and the intensity information.
 28. An image processing apparatus according to claim 27, wherein: the defect information generating unit moves the predetermined range over which the average value is calculated for each target pixel and generates continuous sets of information related to the intensity of the projected image of the defect within the optical path.
 29. (canceled)
 30. (canceled)
 31. An image processing apparatus according to claim 8, wherein: the defect information generating unit simultaneously generates information indicating a position of the projected image of the defect within the optical path and information indicating intensity of the projected image of the defect within the optical path and records the position information and the intensity information.
 32. An image processing apparatus according to claim 31, wherein: the defect information generating unit moves the predetermined range over which the average value is calculated for each target pixel and generates continuous sets of information related to the intensity of the projected image of the defect within the optical path.
 33. (canceled)
 34. (canceled)
 35. An image processing apparatus according to claim 1, wherein: the predetermined range containing the target pixel is greater than a range over which the projected image of the defect within the optical path spreads inside the image.
 36. An image processing apparatus according to claim 1, wherein: the predetermined range containing the target pixel is greater than a range over which the projected image of the defect within the optical path spreads inside the reference image.
 37. An image processing apparatus comprising: an image obtaining unit that obtains a first image photographed through an optical system and a second image photographed under optical conditions different from optical conditions in which the first image is photographed; and a defect information generating unit that generates defect information indicating a defect in the first image or the second image by using the first image and the second image, wherein: the first image and the second image are photographed under different optical conditions with regard to at least either of an aperture value and a pupil position.
 38. An image processing apparatus according to claim 37, further comprising: a correction unit that corrects a defect in the first image or the second image by using the defect information.
 39. (canceled)
 40. An image processing apparatus according to claim 37, wherein: the defect information generating unit includes an optical condition conversion unit that converts at least either the first image or the second image so as to conform to a specific optical condition, in order to eliminate a mismatch of the optical conditions for the first image and the second image.
 41. An image processing apparatus according to claim 40, wherein: if the optical conditions with regard to the aperture value are different, the optical condition conversion unit executes low pass filter processing on a pixel signal generated based upon the first image or the second image so as to convert a defect state corresponding to the first image or the second image to a defect state estimated to manifest at a matching aperture value.
 42. An image processing apparatus according to claim 41, wherein: the optical condition conversion unit executes conversion by using a substantially uniformly weighted low pass filter.
 43. An image processing apparatus according to claim 40, wherein: if the optical conditions with regard to the pupil position are different, the optical condition conversion unit executes displacement processing through which a pixel signal generated based upon the first image or the second image is displaced from a center of an optical axis of the optical system along a direction of a radius vector so as to covert a defect state corresponding to the first image or the second image to a defect state estimated to manifest at a matching pupil position.
 44. An image processing apparatus according to claim 43, wherein: the optical condition conversion unit executes displacement processing through which a pixel signal located further away from the center of the optical axis is shifted to a greater extent along the radius vector.
 45. An image processing apparatus according to claim 43, wherein: the optical condition conversion unit executes the displacement processing by executing an arithmetic operation to predict an extent of displacement on an assumption that foreign matter causing the defect is present over a specific distance from an image-capturing surface within the optical system along the optical axis.
 46. An image processing apparatus according to claim 37, wherein: one of the first image and the second image is a correction target image to undergo correction and the other image is a reference image used to generate the defect information.
 47. An image processing apparatus according to claim 37, wherein: the first image and the second image are both correction target images to undergo correction; and the defect information generating unit generates defect information to be used commonly in conjunction with the first image and the second image by using the first image and the second image.
 48. An image processing apparatus according to claim 47, wherein: the defect information generating unit includes an optical condition conversion unit that converts at least either the first image or the second image so as to conform to a specific optical condition, in order to eliminate a mismatch of the optical conditions for the first image and the second image.
 49. An image processing apparatus according to claim 46, wherein: the image obtaining unit obtains the reference image photographed at an aperture value corresponding to a narrowest aperture opening setting in an adjustable aperture value range of the optical system.
 50. An image processing apparatus according to claim 37, wherein: the defect information generating unit generates defect information indicating a defect within the image having been obtained, based upon a value of a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel in the image.
 51. An image processing apparatus according to claim 46, wherein: the image obtaining unit obtains a reference image photographed within a predetermined period of time preceding or following a time point at which the correction target image is photographed.
 52. An image processing apparatus comprising: an image obtaining unit that obtains a first image photographed through an optical system and a second image photographed under optical conditions different from optical conditions in which the first image is photographed; and a correction unit that corrects a defect contained within the first image or the second image by using the first image and the second image, wherein: the first image and the second image are photographed under different optical conditions with regard to at least either of an aperture value and a pupil position.
 53. (canceled)
 54. An image processing apparatus comprising: an image obtaining unit that obtains a photographic image captured with an image sensor; a flat portion extraction unit that extracts a flat portion area within the photographic image having been obtained; and a defect information generating unit that generates defect information corresponding to the extracted flat portion area.
 55. An image processing apparatus according to claim 54, further comprising: a correction unit that corrects an image within the flat portion area based upon the defect information.
 56. An image processing apparatus according to claim 54, wherein: the defect information corresponding to the flat portion area is generated based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel in the image within the flat portion area.
 57. An image processing apparatus according to claim 56, wherein: the defect information generating unit includes a relative ratio calculation unit that calculates a relative ratio of the value at the target pixel and the average value of the plurality of pixel values corresponding to the pixels present within the predetermined range containing the target pixel, and generates the defect information corresponding to the flat portion area based upon the calculated relative ratio.
 58. An image processing apparatus according to claim 55, further comprising: a relative ratio calculation unit that calculates a relative ratio of a value at a target pixel and an average value of pixel values corresponding to a plurality of pixels present within a predetermined range containing the target pixel, among pixels constituting an image of the flat portion area, wherein: the defect information generating unit generates the defect information corresponding to the flat portion area based upon the relative ratio having been calculated; and the correction unit uses a reciprocal of the relative ratio corresponding to a pixel in the image of the flat portion area when correcting a value of the corresponding pixel in the image of the flat portion area by multiplying the pixel value by the reciprocal.
 59. An image processing apparatus according to claim 58, wherein: the correction unit executes low pass processing on the relative ratio which has been generated as the defect information and corrects the value of the corresponding pixel in the image of the flat portion area by multiplying the pixel value by a reciprocal of the relative ratio having undergone the low pass processing, which corresponds to the pixel in the image of the flat portion area.
 60. An image processing apparatus according to claim 54, wherein: the flat portion extraction unit executes edge extraction within the photographic image and extracts an area in which no edge is extracted as a flat portion area.
 61. An image processing apparatus according to claim 54, wherein: the flat portion extraction unit includes a gradation conversion unit that executes gradation conversion on the photographic image and executes a flat portion area extraction on the photographic image having undergone the gradation conversion.
 62. An image processing apparatus according to claim 61, wherein: when gradation of the photographic image is indicated with a linear signal, the gradation conversion unit converts the linear signal to a nonlinear signal and executes conversion by enlarging the gradation on a low intensity side and compressing the gradation on a high intensity side.
 63. (canceled)
 64. An image processing apparatus according to claim 62, wherein: the gradation conversion unit executes conversion by using a square root function.
 65. (canceled)
 66. An image processing apparatus according to claim 60, wherein: the edge extraction is executed by calculating differences corresponding to a plurality of distances between a target pixel and surrounding pixels along a plurality of directions.
 67. An image processing apparatus according to claim 55, further comprising: a luminance level decision-making unit that makes a decision as to whether or not a luminance level of the photographic image is equal to or higher than a predetermined luminance level, wherein: the correction unit executes correction for an area determined to be a flat portion area, where the luminance level is equal to or greater than the predetermined level.
 68. An image processing apparatus according to claim 54, further comprising: a reference image obtaining unit that obtains a reference image captured with the image sensor; and a reference image defect information generating unit that generates defect information corresponding to the reference image, wherein: the defect information generating unit generates the defect information corresponding to the flat portion area by using area information included in the defect information for the reference image and area information corresponding to the flat portion area in combination.
 69. An image processing apparatus according to claim 68, wherein: if an area that is not extracted as the flat portion area is still indicated to be a defect area by the defect information for the reference image, the flat portion extraction unit extracts the defect area as a flat portion area.
 70. An image processing apparatus according to claim 68, wherein: the defect information generating unit generates the defect information for an area indicated as a defect area by the defect information for the reference image and also determined to be the flat portion area.
 71. An image processing apparatus according to claim 68, further comprising: a defect information conversion unit that converts the defect information for the reference image to defect information equivalent to defect information for a reference image photographed under optical conditions identical to optical conditions under which the photographic image has been photographed when the photographic image and the reference image have been photographed under different optical conditions, wherein: the defect information generating unit uses the defect information for the reference image resulting from the conversion.
 72. An image processing apparatus according to claim 69, further comprising: a defect information conversion unit that converts the defect information for the reference image to defect information equivalent to defect information for a reference image photographed under optical conditions identical to optical conditions under which the photographic image has been photographed when the photographic image and the reference image have been photographed under different optical conditions, wherein: the flat portion extraction unit uses the defect information for the reference image resulting from the conversion.
 73. An image processing apparatus according to claim 72, wherein: in consideration of an error in defect information conversion executed by the defect information conversion unit, the defect information generating unit expands the defect area indicated by the defect information for the reference image, at least by an extent corresponding to the error in the defect information conversion.
 74. An image processing apparatus according to claim 54, wherein: the image obtaining unit obtains a plurality of photographic images captured with the image sensor; the flat portion extraction unit extracts the flat portion area in each of the plurality of photographic images; and the defect information generating unit generates defect information corresponding to the flat portion area in one of the plurality of images by using images of flat portion areas in the plurality of images having been extracted.
 75. An image processing apparatus according to claim 54, wherein: the image obtaining unit obtains a plurality of photographic images captured with the image sensor; the flat portion extraction unit extracts the flat portion area in each of the plurality of photographic images; and the defect information generating unit generates defect information corresponding to an entire image of each of the plurality of images by using images of flat portion areas in the plurality of images having been extracted.
 76. An image processing apparatus according to claim 75, wherein: the defect information corresponding to the flat portion area is generated based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel in the image within the flat portion area.
 77. An image processing apparatus according to claim 76, wherein: the defect information generating unit includes a relative ratio calculation unit that calculates a relative ratio of the value at the target pixel and the average value of the plurality of pixel values corresponding to the pixels present within the predetermined range containing the target pixel, and generates the defect information corresponding to the flat portion area based upon the calculated relative ratio.
 78. An image processing apparatus according to claim 69, wherein: if there are a predetermined number of pixels or more pixels from which an edge has been extracted are present around the defect area indicated by the defect information for the reference image, the flat portion extraction unit does not extract the defect area as the flat portion area.
 79. An image processing apparatus according to claim 78, wherein: if an edge has been extracted from a majority of pixels among pixels present in a predetermined area surrounding a pixel in the defective area, the flat portion extraction unit does not extract the pixel in the defect area as a pixel in the flat portion.
 80. A computer-readable computer program product having an image processing program enabling a computer to execute functions of an image processing apparatus according to claim
 1. 81. An image processing apparatus comprising: an image obtaining unit that obtains an image captured with an image sensor; and a defect information generating unit that generates defect information indicating a defect within the image having been obtained, based upon a value at a target pixel and an average value of a plurality of pixel values corresponding to pixels present within a predetermined range containing the target pixel, wherein: the predetermined range containing the target pixel is greater than a defect area manifesting within the image.
 82. An image processing apparatus according to claim 27, wherein: the defect information generating unit includes a relative ratio calculation unit that calculates a relative ratio of the value at the target pixel and the average value of the plurality of pixel values corresponding to the pixels present within the predetermined range containing the target pixel, and generates the defect information based upon the calculated relative ratio.
 83. An image processing apparatus according to claim 82, wherein: the defect information generating unit generates defect information for an area within the image, which satisfies a predetermined condition.
 84. An image processing apparatus according to claim 31, wherein: the defect information generating unit includes a relative ratio calculation unit that calculates a relative ratio of the value at the target pixel and the average value of the plurality of pixel values corresponding to the pixels present within the predetermined range containing the target pixel, and generates the defect information based upon the calculated relative ratio.
 85. An image processing apparatus according to claim 84, wherein: the relative ratio calculation unit sets the calculated relative ratio to 1 if the calculated relative ratio falls within a predetermined range containing
 1. 86. An image processing apparatus according to claim 85, wherein: the relative ratio calculation unit correlates the predetermined range over which the calculated relative ratio is set to 1 with a standard deviation value of the calculated relative ratio.
 87. An image processing apparatus according to claim 86, wherein: the relative ratio calculation unit sets the predetermined range over which the calculated relative ratio is set to 1 to a ±(3×standard deviation value) range.
 88. A computer-readable computer program product having an image processing program enabling a computer to execute functions of an image processing apparatus according to claim
 37. 89. A computer-readable computer program product having an image processing program enabling a computer to execute functions of an image processing apparatus according to claim
 54. 